diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef3c851..13198a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-2019] + features: [default, bundled] runs-on: ${{ matrix.os }} steps: - name: Checkout sources @@ -63,21 +64,22 @@ jobs: - name: Check shell: bash run: | - cargo check + cargo check --no-default-features --features "${{ matrix.features }}" - name: Tests shell: bash run: | - cargo test + cargo test --no-default-features --features "${{ matrix.features }}" - name: Test compile diesel shell: bash run: | cargo new test_diesel cd test_diesel + echo "[workspace]" >> Cargo.toml cargo add diesel --no-default-features --features "postgres" + cargo add pq-sys echo "[patch.crates-io]" >> Cargo.toml echo "pq-sys = { path = \"..\" }" >> Cargo.toml cat Cargo.toml echo "use diesel::prelude::*;" > src/main.rs echo "fn main() { PgConnection::establish(\"foo\").unwrap(); }" >> src/main.rs - cat src/main.rs - cargo build + cargo build --features "pq-sys/${{ matrix.features }}" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b5eb492 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "pq-src/source"] + path = pq-src/source + url = https://github.com/postgres/postgres diff --git a/Cargo.toml b/Cargo.toml index 76aee6d..43a1b0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,11 +7,21 @@ repository = "https://github.com/sgrif/pq-sys" links = "pq" build = "build.rs" +[workspace] +members = ["pq-src"] + [lib] name = "pq_sys" +[dependencies] +pq-src = { path = "pq-src", optional = true } + [build-dependencies] pkg-config = { version = "0.3.0", optional = true } [target.'cfg(target_env = "msvc")'.build-dependencies] vcpkg = "0.2.6" + +[features] +default = [] +bundled = ["pq-src"] diff --git a/build.rs b/build.rs index 2640f27..74bb3f9 100644 --- a/build.rs +++ b/build.rs @@ -77,6 +77,12 @@ impl Display for LinkingOptions { } fn main() { + if cfg!(feature = "bundled") { + // everything else is handled + // by pq-src + return; + } + println!("cargo:rerun-if-env-changed=PQ_LIB_STATIC"); println!("cargo:rerun-if-env-changed=TARGET"); diff --git a/pq-src/.gitignore b/pq-src/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/pq-src/.gitignore @@ -0,0 +1 @@ +/target diff --git a/pq-src/Cargo.toml b/pq-src/Cargo.toml new file mode 100644 index 0000000..1ffee61 --- /dev/null +++ b/pq-src/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "pq-src" +version = "0.1.0" +edition = "2021" +include = [ + "src/*", + "build.rs", + "additional_include/pg_config.h", + "additional_include/pg_config_paths.h", + + "source/src/include/*", + "source/src/port/*", + "source/src/common/*", + "source/src/interfaces/libpq/*", +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +openssl-sys = { version = "0.9.93", features = ["vendored"] } + + +[build-dependencies] +cc = "1.0.83" diff --git a/pq-src/additional_include/pg_config.h b/pq-src/additional_include/pg_config.h new file mode 100644 index 0000000..172d7c9 --- /dev/null +++ b/pq-src/additional_include/pg_config.h @@ -0,0 +1,244 @@ +/* src/include/pg_config.h. Generated from pg_config.h.in by configure. */ +/* src/include/pg_config.h.in. Generated from configure.ac by autoheader. */ + +/* Size of a disk block --- this also limits the size of a tuple. You can set + it bigger if you need bigger tuples (although TOAST should reduce the need + to have large tuples, since fields can be spread across multiple tuples). + BLCKSZ must be a power of 2. The maximum possible value of BLCKSZ is + currently 2^15 (32768). This is determined by the 15-bit widths of the + lp_off and lp_len fields in ItemIdData (see include/storage/itemid.h). + Changing BLCKSZ requires an initdb. */ +#define BLCKSZ 8192 + +/* Saved arguments from configure */ +#define CONFIGURE_ARGS " '--with-openssl' '--without-readline'" + +/* Define to the default TCP port number on which the server listens and to + which clients will try to connect. This can be overridden at run-time, but + it's convenient if your clients have the right default compiled in. + (--with-pgport=PORTNUM) */ +#define DEF_PGPORT 5432 + +/* Define to the default TCP port number as a string constant. */ +#define DEF_PGPORT_STR "5432" + +/* Define to 1 to build client libraries as thread-safe code. + (--enable-thread-safety) */ +#define ENABLE_THREAD_SAFETY 1 + +/* Define to 1 if you have the `ASN1_STRING_get0_data' function. */ +#define HAVE_ASN1_STRING_GET0_DATA 1 + +/* Define to 1 if you want to use atomics if available. */ +#define HAVE_ATOMICS 1 + +/* Define to 1 if you have the `backtrace_symbols' function. */ +#define HAVE_BACKTRACE_SYMBOLS 1 + +/* /\* Define to 1 if you have the `BIO_get_data' function. *\/ */ +#define HAVE_BIO_GET_DATA 1 + +/* /\* Define to 1 if you have the `BIO_meth_new' function. *\/ */ +#define HAVE_BIO_METH_NEW 1 + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#define HAVE_LIBCRYPTO 1 + +/* Define to 1 if you have the `m' library (-lm). */ +#define HAVE_LIBM 1 + +/* Define to 1 if you have the `ssl' library (-lssl). */ +#define HAVE_LIBSSL 1 + +/* Define to 1 if `long int' works and is 64 bits. */ +#define HAVE_LONG_INT_64 1 + +/* Define to 1 if you have the `OPENSSL_init_ssl' function. */ +#define HAVE_OPENSSL_INIT_SSL 1 + +/* Define to 1 if you have the `SSL_CTX_set_cert_cb' function. */ +#define HAVE_SSL_CTX_SET_CERT_CB 1 + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchrnul' function. */ +#define HAVE_STRCHRNUL 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strnlen' function. */ +#define HAVE_STRNLEN 1 + +/* Define to 1 if you have the `strsignal' function. */ +#define HAVE_STRSIGNAL 1 + +/* Define to 1 if your compiler understands `typeof' or something similar. */ +#define HAVE_TYPEOF 1 + +/* Define to 1 if you have the `X509_get_signature_info' function. */ +#define HAVE_X509_GET_SIGNATURE_INFO 1 + +/* Define to 1 if you have the `X509_get_signature_nid' function. */ +#define HAVE_X509_GET_SIGNATURE_NID 1 + +/* Define to 1 if your compiler understands _Static_assert. */ +#define HAVE__STATIC_ASSERT 1 + +/* Define as the maximum alignment requirement of any C data type. */ +#define MAXIMUM_ALIGNOF 8 + +/* /\* Define bytes to use libc memset(). *\/ */ +#define MEMSET_LOOP_LIMIT 1024 + +/* Define to the OpenSSL API version in use. This avoids deprecation warnings + from newer OpenSSL versions. */ +#define OPENSSL_API_COMPAT 0x10001000L + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "pgsql-bugs@lists.postgresql.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "PostgreSQL" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "PostgreSQL 16.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "postgresql" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "https://www.postgresql.org/" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "16.0" + +/* Define to the name of a signed 128-bit integer type. */ +#define PG_INT128_TYPE __int128 + +/* Define to the name of a signed 64-bit integer type. */ +#define PG_INT64_TYPE long int + +/* Define to the name of the default PostgreSQL service principal in Kerberos + (GSSAPI). (--with-krb-srvnam=NAME) */ +#define PG_KRB_SRVNAM "postgres" + +/* PostgreSQL major version as a string */ +#define PG_MAJORVERSION "16" + +/* PostgreSQL major version number */ +#define PG_MAJORVERSION_NUM 16 + +/* PostgreSQL minor version number */ +#define PG_MINORVERSION_NUM 0 + +/* Define to best printf format archetype, usually gnu_printf if available. */ +#define PG_PRINTF_ATTRIBUTE gnu_printf + +/* Define to 1 to use to define type bool. */ +#define PG_USE_STDBOOL 1 + +/* PostgreSQL version as a string */ +#define PG_VERSION "16.0" + +/* PostgreSQL version as a number */ +#define PG_VERSION_NUM 160000 + +/* A string containing the version number, platform, and C compiler */ +#define PG_VERSION_STR "PostgreSQL 16.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1), 64-bit" + + +/* RELSEG_SIZE is the maximum number of blocks allowed in one disk file. Thus, + the maximum size of a single file is RELSEG_SIZE * BLCKSZ; relations bigger + than that are divided into multiple files. RELSEG_SIZE * BLCKSZ must be + less than your OS' limit on file size. This is often 2 GB or 4GB in a + 32-bit operating system, unless you have large file support enabled. By + default, we make the limit 1 GB to avoid any possible integer-overflow + problems within the OS. A limit smaller than necessary only means we divide + a large relation into more chunks than necessary, so it seems best to err + in the direction of a small limit. A power-of-2 value is recommended to + save a few cycles in md.c, but is not absolutely required. Changing + RELSEG_SIZE requires an initdb. */ +#define RELSEG_SIZE 131072 + +/* The size of `bool', as computed by sizeof. */ +#define SIZEOF_BOOL 1 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + + +/* Define to 1 to build with OpenSSL support. (--with-ssl=openssl) */ +#define USE_OPENSSL 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Size of a WAL file block. This need have no particular relation to BLCKSZ. + XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O, + XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O + buffers, else direct I/O may fail. Changing XLOG_BLCKSZ requires an initdb. + */ +#define XLOG_BLCKSZ 8192 + + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to keyword to use for C99 restrict support, or to nothing if not + supported */ +#define pg_restrict __restrict + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#define restrict __restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + +/* Define to how the compiler spells `typeof'. */ +/* #undef typeof */ diff --git a/pq-src/additional_include/pg_config_paths.h b/pq-src/additional_include/pg_config_paths.h new file mode 100644 index 0000000..8d16c70 --- /dev/null +++ b/pq-src/additional_include/pg_config_paths.h @@ -0,0 +1,12 @@ +#define PGBINDIR "/usr/local/pgsql/bin" +#define PGSHAREDIR "/usr/local/pgsql/share" +#define SYSCONFDIR "/usr/local/pgsql/etc" +#define INCLUDEDIR "/usr/local/pgsql/include" +#define PKGINCLUDEDIR "/usr/local/pgsql/include" +#define INCLUDEDIRSERVER "/usr/local/pgsql/include/server" +#define LIBDIR "/usr/local/pgsql/lib" +#define PKGLIBDIR "/usr/local/pgsql/lib" +#define LOCALEDIR "/usr/local/pgsql/share/locale" +#define DOCDIR "/usr/local/pgsql/share/doc/" +#define HTMLDIR "/usr/local/pgsql/share/doc/" +#define MANDIR "/usr/local/pgsql/share/man" diff --git a/pq-src/build.rs b/pq-src/build.rs new file mode 100644 index 0000000..4109768 --- /dev/null +++ b/pq-src/build.rs @@ -0,0 +1,110 @@ +const LIBPORTS: &'static [&'static str] = &[ + "getpeereid.c", + "strlcat.c", + "strlcpy.c", + "snprintf.c", + "pg_crc32c_sb8.c", + "bsearch_arg.c", + "chklocale.c", + "inet_net_ntop.c", + "noblock.c", + "pg_bitutils.c", + "pg_strong_random.c", + "pgcheckdir.c", + "pgmkdirp.c", + "pgsleep.c", + "pgstrcasecmp.c", + "pgstrsignal.c", + "pqsignal.c", + "qsort.c", + "quotes.c", + "strerror.c", + "tar.c", + "thread.c", +]; + +const LIBCOMMON: &'static [&'static str] = &[ + "file_perm.c", + "ip.c", + "jsonapi.c", + "kwlookup.c", + "link-canary.c", + "md5_common.c", + "percentrepl.c", + "pg_get_line.c", + "pg_lzcompress.c", + "pg_prng.c", + "pgfnames.c", + "psprintf.c", + "rmtree.c", + "saslprep.c", + "string.c", + "stringinfo.c", + "unicode_norm.c", + "username.c", + "wait_error.c", + "wchar.c", + "cryptohash_openssl.c", + "hmac_openssl.c", + "protocol_openssl.c", + "fe_memutils.c", + "restricted_token.c", + "sprompt.c", + "logging.c", +]; + +const LIBPQ: &'static [&'static str] = &[ + "fe-connect.c", + "fe-exec.c", + "fe-lobj.c", + "fe-misc.c", + "fe-print.c", + "fe-protocol3.c", + "fe-secure.c", + "fe-trace.c", + "legacy-pqsignal.c", + "libpq-events.c", + "pqexpbuffer.c", + "fe-auth.c", + "fe-secure-common.c", + "fe-secure-openssl.c", + "fe-auth-scram.c", +]; + +fn main() { + println!("cargo:rerun-if-changed=additional_include"); + let crate_dir = env!("CARGO_MANIFEST_DIR"); + let path = format!("{crate_dir}/source/"); + let port_path = "src/port/"; + let common_path = "src/common/"; + let pq_path = "src/interfaces/libpq/"; + + cc::Build::new() + .define("FRONTEND", None) + .define("_GNU_SOURCE", None) + .warnings(false) + .includes([format!("{path}{port_path}"), format!("{path}src/include")]) + .files(LIBPORTS.iter().map(|p| format!("{path}{port_path}{p}"))) + .compile("ports"); + + cc::Build::new() + .define("FRONTEND", None) + .define("_GNU_SOURCE", None) + .warnings(false) + .includes([format!("{path}{common_path}"), format!("{path}src/include")]) + .files(LIBCOMMON.iter().map(|p| format!("{path}{common_path}{p}"))) + .compile("pgcommon"); + + cc::Build::new() + .define("FRONTEND", None) + .define("_GNU_SOURCE", None) + .warnings(false) + .includes([ + format!("{path}{port_path}"), + format!("{path}src/include"), + format!("{crate_dir}/additional_include"), + ]) + .files(LIBPQ.iter().map(|p| format!("{path}{pq_path}{p}"))) + .compile("pq"); + +} diff --git a/pq-src/source b/pq-src/source new file mode 160000 index 0000000..c372fbb --- /dev/null +++ b/pq-src/source @@ -0,0 +1 @@ +Subproject commit c372fbbd8e911f2412b80a8c39d7079366565d67 diff --git a/pq-src/src/lib.rs b/pq-src/src/lib.rs new file mode 100644 index 0000000..176961b --- /dev/null +++ b/pq-src/src/lib.rs @@ -0,0 +1 @@ +extern crate openssl_sys; diff --git a/src/bindings.rs b/src/bindings.rs new file mode 100644 index 0000000..158cc50 --- /dev/null +++ b/src/bindings.rs @@ -0,0 +1,905 @@ +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] + +/* automatically generated by rust-bindgen */ + +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } +} +impl ::std::marker::Copy for __BindgenUnionField { } +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +pub type __int64_t = ::std::os::raw::c_longlong; +pub type __darwin_size_t = ::std::os::raw::c_ulong; +pub type __darwin_off_t = __int64_t; +pub type fpos_t = __darwin_off_t; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct __sbuf { + pub _base: *mut ::std::os::raw::c_uchar, + pub _size: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout___sbuf() { + assert_eq!(::std::mem::size_of::<__sbuf>() , 16usize); + assert_eq!(::std::mem::align_of::<__sbuf>() , 8usize); +} +impl Clone for __sbuf { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __sFILEX([u8; 0]); +#[repr(C)] +#[derive(Debug, Copy)] +pub struct __sFILE { + pub _p: *mut ::std::os::raw::c_uchar, + pub _r: ::std::os::raw::c_int, + pub _w: ::std::os::raw::c_int, + pub _flags: ::std::os::raw::c_short, + pub _file: ::std::os::raw::c_short, + pub _bf: __sbuf, + pub _lbfsize: ::std::os::raw::c_int, + pub _cookie: *mut ::std::os::raw::c_void, + pub _close: ::std::option::Option ::std::os::raw::c_int>, + pub _read: ::std::option::Option ::std::os::raw::c_int>, + pub _seek: ::std::option::Option ::std::os::raw::c_longlong>, + pub _write: ::std::option::Option ::std::os::raw::c_int>, + pub _ub: __sbuf, + pub _extra: *mut __sFILEX, + pub _ur: ::std::os::raw::c_int, + pub _ubuf: [::std::os::raw::c_uchar; 3usize], + pub _nbuf: [::std::os::raw::c_uchar; 1usize], + pub _lb: __sbuf, + pub _blksize: ::std::os::raw::c_int, + pub _offset: fpos_t, +} +#[test] +fn bindgen_test_layout___sFILE() { + assert_eq!(::std::mem::size_of::<__sFILE>() , 152usize); + assert_eq!(::std::mem::align_of::<__sFILE>() , 8usize); +} +impl Clone for __sFILE { + fn clone(&self) -> Self { *self } +} +pub type FILE = __sFILE; +pub type Oid = ::std::os::raw::c_uint; +pub const CONNECTION_OK: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_OK; +pub const CONNECTION_BAD: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_BAD; +pub const CONNECTION_STARTED: _bindgen_ty_2 = + _bindgen_ty_2::CONNECTION_STARTED; +pub const CONNECTION_MADE: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_MADE; +pub const CONNECTION_AWAITING_RESPONSE: _bindgen_ty_2 = + _bindgen_ty_2::CONNECTION_AWAITING_RESPONSE; +pub const CONNECTION_AUTH_OK: _bindgen_ty_2 = + _bindgen_ty_2::CONNECTION_AUTH_OK; +pub const CONNECTION_SETENV: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_SETENV; +pub const CONNECTION_SSL_STARTUP: _bindgen_ty_2 = + _bindgen_ty_2::CONNECTION_SSL_STARTUP; +pub const CONNECTION_NEEDED: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_NEEDED; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_2 { + CONNECTION_OK = 0, + CONNECTION_BAD = 1, + CONNECTION_STARTED = 2, + CONNECTION_MADE = 3, + CONNECTION_AWAITING_RESPONSE = 4, + CONNECTION_AUTH_OK = 5, + CONNECTION_SETENV = 6, + CONNECTION_SSL_STARTUP = 7, + CONNECTION_NEEDED = 8, +} +pub use self::_bindgen_ty_2 as ConnStatusType; +pub const PGRES_POLLING_FAILED: _bindgen_ty_3 = + _bindgen_ty_3::PGRES_POLLING_FAILED; +pub const PGRES_POLLING_READING: _bindgen_ty_3 = + _bindgen_ty_3::PGRES_POLLING_READING; +pub const PGRES_POLLING_WRITING: _bindgen_ty_3 = + _bindgen_ty_3::PGRES_POLLING_WRITING; +pub const PGRES_POLLING_OK: _bindgen_ty_3 = _bindgen_ty_3::PGRES_POLLING_OK; +pub const PGRES_POLLING_ACTIVE: _bindgen_ty_3 = + _bindgen_ty_3::PGRES_POLLING_ACTIVE; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_3 { + PGRES_POLLING_FAILED = 0, + PGRES_POLLING_READING = 1, + PGRES_POLLING_WRITING = 2, + PGRES_POLLING_OK = 3, + PGRES_POLLING_ACTIVE = 4, +} +pub use self::_bindgen_ty_3 as PostgresPollingStatusType; +pub const PGRES_EMPTY_QUERY: _bindgen_ty_4 = _bindgen_ty_4::PGRES_EMPTY_QUERY; +pub const PGRES_COMMAND_OK: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COMMAND_OK; +pub const PGRES_TUPLES_OK: _bindgen_ty_4 = _bindgen_ty_4::PGRES_TUPLES_OK; +pub const PGRES_COPY_OUT: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COPY_OUT; +pub const PGRES_COPY_IN: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COPY_IN; +pub const PGRES_BAD_RESPONSE: _bindgen_ty_4 = + _bindgen_ty_4::PGRES_BAD_RESPONSE; +pub const PGRES_NONFATAL_ERROR: _bindgen_ty_4 = + _bindgen_ty_4::PGRES_NONFATAL_ERROR; +pub const PGRES_FATAL_ERROR: _bindgen_ty_4 = _bindgen_ty_4::PGRES_FATAL_ERROR; +pub const PGRES_COPY_BOTH: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COPY_BOTH; +pub const PGRES_SINGLE_TUPLE: _bindgen_ty_4 = + _bindgen_ty_4::PGRES_SINGLE_TUPLE; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_4 { + PGRES_EMPTY_QUERY = 0, + PGRES_COMMAND_OK = 1, + PGRES_TUPLES_OK = 2, + PGRES_COPY_OUT = 3, + PGRES_COPY_IN = 4, + PGRES_BAD_RESPONSE = 5, + PGRES_NONFATAL_ERROR = 6, + PGRES_FATAL_ERROR = 7, + PGRES_COPY_BOTH = 8, + PGRES_SINGLE_TUPLE = 9, +} +pub use self::_bindgen_ty_4 as ExecStatusType; +pub const PQTRANS_IDLE: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_IDLE; +pub const PQTRANS_ACTIVE: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_ACTIVE; +pub const PQTRANS_INTRANS: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_INTRANS; +pub const PQTRANS_INERROR: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_INERROR; +pub const PQTRANS_UNKNOWN: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_UNKNOWN; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_5 { + PQTRANS_IDLE = 0, + PQTRANS_ACTIVE = 1, + PQTRANS_INTRANS = 2, + PQTRANS_INERROR = 3, + PQTRANS_UNKNOWN = 4, +} +pub use self::_bindgen_ty_5 as PGTransactionStatusType; +pub const PQERRORS_TERSE: _bindgen_ty_6 = _bindgen_ty_6::PQERRORS_TERSE; +pub const PQERRORS_DEFAULT: _bindgen_ty_6 = _bindgen_ty_6::PQERRORS_DEFAULT; +pub const PQERRORS_VERBOSE: _bindgen_ty_6 = _bindgen_ty_6::PQERRORS_VERBOSE; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_6 { + PQERRORS_TERSE = 0, + PQERRORS_DEFAULT = 1, + PQERRORS_VERBOSE = 2, +} +pub use self::_bindgen_ty_6 as PGVerbosity; +pub const PQPING_OK: _bindgen_ty_7 = _bindgen_ty_7::PQPING_OK; +pub const PQPING_REJECT: _bindgen_ty_7 = _bindgen_ty_7::PQPING_REJECT; +pub const PQPING_NO_RESPONSE: _bindgen_ty_7 = + _bindgen_ty_7::PQPING_NO_RESPONSE; +pub const PQPING_NO_ATTEMPT: _bindgen_ty_7 = _bindgen_ty_7::PQPING_NO_ATTEMPT; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_7 { + PQPING_OK = 0, + PQPING_REJECT = 1, + PQPING_NO_RESPONSE = 2, + PQPING_NO_ATTEMPT = 3, +} +pub use self::_bindgen_ty_7 as PGPing; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pg_conn([u8; 0]); +pub type PGconn = pg_conn; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pg_result([u8; 0]); +pub type PGresult = pg_result; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pg_cancel([u8; 0]); +pub type PGcancel = pg_cancel; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct pgNotify { + pub relname: *mut ::std::os::raw::c_char, + pub be_pid: ::std::os::raw::c_int, + pub extra: *mut ::std::os::raw::c_char, + pub next: *mut pgNotify, +} +#[test] +fn bindgen_test_layout_pgNotify() { + assert_eq!(::std::mem::size_of::() , 32usize); + assert_eq!(::std::mem::align_of::() , 8usize); +} +impl Clone for pgNotify { + fn clone(&self) -> Self { *self } +} +pub type PGnotify = pgNotify; +pub type PQnoticeReceiver = + ::std::option::Option; +pub type PQnoticeProcessor = + ::std::option::Option; +pub type pqbool = ::std::os::raw::c_char; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct _PQprintOpt { + pub header: pqbool, + pub align: pqbool, + pub standard: pqbool, + pub html3: pqbool, + pub expanded: pqbool, + pub pager: pqbool, + pub fieldSep: *mut ::std::os::raw::c_char, + pub tableOpt: *mut ::std::os::raw::c_char, + pub caption: *mut ::std::os::raw::c_char, + pub fieldName: *mut *mut ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout__PQprintOpt() { + assert_eq!(::std::mem::size_of::<_PQprintOpt>() , 40usize); + assert_eq!(::std::mem::align_of::<_PQprintOpt>() , 8usize); +} +impl Clone for _PQprintOpt { + fn clone(&self) -> Self { *self } +} +pub type PQprintOpt = _PQprintOpt; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct _PQconninfoOption { + pub keyword: *mut ::std::os::raw::c_char, + pub envvar: *mut ::std::os::raw::c_char, + pub compiled: *mut ::std::os::raw::c_char, + pub val: *mut ::std::os::raw::c_char, + pub label: *mut ::std::os::raw::c_char, + pub dispchar: *mut ::std::os::raw::c_char, + pub dispsize: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout__PQconninfoOption() { + assert_eq!(::std::mem::size_of::<_PQconninfoOption>() , 56usize); + assert_eq!(::std::mem::align_of::<_PQconninfoOption>() , 8usize); +} +impl Clone for _PQconninfoOption { + fn clone(&self) -> Self { *self } +} +pub type PQconninfoOption = _PQconninfoOption; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct _bindgen_ty_8 { + pub len: ::std::os::raw::c_int, + pub isint: ::std::os::raw::c_int, + pub u: _bindgen_ty_8__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct _bindgen_ty_8__bindgen_ty_1 { + pub ptr: __BindgenUnionField<*mut ::std::os::raw::c_int>, + pub integer: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u64, +} +#[test] +fn bindgen_test_layout__bindgen_ty_8__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_8__bindgen_ty_1>() , 8usize); + assert_eq!(::std::mem::align_of::<_bindgen_ty_8__bindgen_ty_1>() , + 8usize); +} +impl Clone for _bindgen_ty_8__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +#[test] +fn bindgen_test_layout__bindgen_ty_8() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_8>() , 16usize); + assert_eq!(::std::mem::align_of::<_bindgen_ty_8>() , 8usize); +} +impl Clone for _bindgen_ty_8 { + fn clone(&self) -> Self { *self } +} +pub type PQArgBlock = _bindgen_ty_8; +#[repr(C)] +#[derive(Debug, Copy)] +pub struct pgresAttDesc { + pub name: *mut ::std::os::raw::c_char, + pub tableid: Oid, + pub columnid: ::std::os::raw::c_int, + pub format: ::std::os::raw::c_int, + pub typid: Oid, + pub typlen: ::std::os::raw::c_int, + pub atttypmod: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pgresAttDesc() { + assert_eq!(::std::mem::size_of::() , 32usize); + assert_eq!(::std::mem::align_of::() , 8usize); +} +impl Clone for pgresAttDesc { + fn clone(&self) -> Self { *self } +} +pub type PGresAttDesc = pgresAttDesc; +extern "C" { + pub fn PQconnectStart(conninfo: *const ::std::os::raw::c_char) + -> *mut PGconn; +} +extern "C" { + pub fn PQconnectStartParams(keywords: + *const *const ::std::os::raw::c_char, + values: *const *const ::std::os::raw::c_char, + expand_dbname: ::std::os::raw::c_int) + -> *mut PGconn; +} +extern "C" { + pub fn PQconnectPoll(conn: *mut PGconn) -> PostgresPollingStatusType; +} +extern "C" { + pub fn PQconnectdb(conninfo: *const ::std::os::raw::c_char) + -> *mut PGconn; +} +extern "C" { + pub fn PQconnectdbParams(keywords: *const *const ::std::os::raw::c_char, + values: *const *const ::std::os::raw::c_char, + expand_dbname: ::std::os::raw::c_int) + -> *mut PGconn; +} +extern "C" { + pub fn PQsetdbLogin(pghost: *const ::std::os::raw::c_char, + pgport: *const ::std::os::raw::c_char, + pgoptions: *const ::std::os::raw::c_char, + pgtty: *const ::std::os::raw::c_char, + dbName: *const ::std::os::raw::c_char, + login: *const ::std::os::raw::c_char, + pwd: *const ::std::os::raw::c_char) -> *mut PGconn; +} +extern "C" { + pub fn PQfinish(conn: *mut PGconn); +} +extern "C" { + pub fn PQconndefaults() -> *mut PQconninfoOption; +} +extern "C" { + pub fn PQconninfoParse(conninfo: *const ::std::os::raw::c_char, + errmsg: *mut *mut ::std::os::raw::c_char) + -> *mut PQconninfoOption; +} +extern "C" { + pub fn PQconninfo(conn: *mut PGconn) -> *mut PQconninfoOption; +} +extern "C" { + pub fn PQconninfoFree(connOptions: *mut PQconninfoOption); +} +extern "C" { + pub fn PQresetStart(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQresetPoll(conn: *mut PGconn) -> PostgresPollingStatusType; +} +extern "C" { + pub fn PQreset(conn: *mut PGconn); +} +extern "C" { + pub fn PQgetCancel(conn: *mut PGconn) -> *mut PGcancel; +} +extern "C" { + pub fn PQfreeCancel(cancel: *mut PGcancel); +} +extern "C" { + pub fn PQcancel(cancel: *mut PGcancel, + errbuf: *mut ::std::os::raw::c_char, + errbufsize: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQrequestCancel(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQdb(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQuser(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQpass(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQhost(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQport(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQtty(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQoptions(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQstatus(conn: *const PGconn) -> ConnStatusType; +} +extern "C" { + pub fn PQtransactionStatus(conn: *const PGconn) + -> PGTransactionStatusType; +} +extern "C" { + pub fn PQparameterStatus(conn: *const PGconn, + paramName: *const ::std::os::raw::c_char) + -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn PQprotocolVersion(conn: *const PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQserverVersion(conn: *const PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQerrorMessage(conn: *const PGconn) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQsocket(conn: *const PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQbackendPID(conn: *const PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQconnectionNeedsPassword(conn: *const PGconn) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQconnectionUsedPassword(conn: *const PGconn) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQclientEncoding(conn: *const PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsetClientEncoding(conn: *mut PGconn, + encoding: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsslInUse(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsslStruct(conn: *mut PGconn, + struct_name: *const ::std::os::raw::c_char) + -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn PQsslAttribute(conn: *mut PGconn, + attribute_name: *const ::std::os::raw::c_char) + -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn PQsslAttributeNames(conn: *mut PGconn) + -> *const *const ::std::os::raw::c_char; +} +extern "C" { + pub fn PQgetssl(conn: *mut PGconn) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn PQinitSSL(do_init: ::std::os::raw::c_int); +} +extern "C" { + pub fn PQinitOpenSSL(do_ssl: ::std::os::raw::c_int, + do_crypto: ::std::os::raw::c_int); +} +extern "C" { + pub fn PQsetErrorVerbosity(conn: *mut PGconn, verbosity: PGVerbosity) + -> PGVerbosity; +} +extern "C" { + pub fn PQtrace(conn: *mut PGconn, debug_port: *mut FILE); +} +extern "C" { + pub fn PQuntrace(conn: *mut PGconn); +} +extern "C" { + pub fn PQsetNoticeReceiver(conn: *mut PGconn, proc_: PQnoticeReceiver, + arg: *mut ::std::os::raw::c_void) + -> PQnoticeReceiver; +} +extern "C" { + pub fn PQsetNoticeProcessor(conn: *mut PGconn, proc_: PQnoticeProcessor, + arg: *mut ::std::os::raw::c_void) + -> PQnoticeProcessor; +} +pub type pgthreadlock_t = + ::std::option::Option; +extern "C" { + pub fn PQregisterThreadLock(newhandler: pgthreadlock_t) -> pgthreadlock_t; +} +extern "C" { + pub fn PQexec(conn: *mut PGconn, query: *const ::std::os::raw::c_char) + -> *mut PGresult; +} +extern "C" { + pub fn PQexecParams(conn: *mut PGconn, + command: *const ::std::os::raw::c_char, + nParams: ::std::os::raw::c_int, + paramTypes: *const Oid, + paramValues: *const *const ::std::os::raw::c_char, + paramLengths: *const ::std::os::raw::c_int, + paramFormats: *const ::std::os::raw::c_int, + resultFormat: ::std::os::raw::c_int) -> *mut PGresult; +} +extern "C" { + pub fn PQprepare(conn: *mut PGconn, + stmtName: *const ::std::os::raw::c_char, + query: *const ::std::os::raw::c_char, + nParams: ::std::os::raw::c_int, paramTypes: *const Oid) + -> *mut PGresult; +} +extern "C" { + pub fn PQexecPrepared(conn: *mut PGconn, + stmtName: *const ::std::os::raw::c_char, + nParams: ::std::os::raw::c_int, + paramValues: *const *const ::std::os::raw::c_char, + paramLengths: *const ::std::os::raw::c_int, + paramFormats: *const ::std::os::raw::c_int, + resultFormat: ::std::os::raw::c_int) + -> *mut PGresult; +} +extern "C" { + pub fn PQsendQuery(conn: *mut PGconn, + query: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsendQueryParams(conn: *mut PGconn, + command: *const ::std::os::raw::c_char, + nParams: ::std::os::raw::c_int, + paramTypes: *const Oid, + paramValues: + *const *const ::std::os::raw::c_char, + paramLengths: *const ::std::os::raw::c_int, + paramFormats: *const ::std::os::raw::c_int, + resultFormat: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsendPrepare(conn: *mut PGconn, + stmtName: *const ::std::os::raw::c_char, + query: *const ::std::os::raw::c_char, + nParams: ::std::os::raw::c_int, + paramTypes: *const Oid) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsendQueryPrepared(conn: *mut PGconn, + stmtName: *const ::std::os::raw::c_char, + nParams: ::std::os::raw::c_int, + paramValues: + *const *const ::std::os::raw::c_char, + paramLengths: *const ::std::os::raw::c_int, + paramFormats: *const ::std::os::raw::c_int, + resultFormat: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsetSingleRowMode(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQgetResult(conn: *mut PGconn) -> *mut PGresult; +} +extern "C" { + pub fn PQisBusy(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQconsumeInput(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQnotifies(conn: *mut PGconn) -> *mut PGnotify; +} +extern "C" { + pub fn PQputCopyData(conn: *mut PGconn, + buffer: *const ::std::os::raw::c_char, + nbytes: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQputCopyEnd(conn: *mut PGconn, + errormsg: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQgetCopyData(conn: *mut PGconn, + buffer: *mut *mut ::std::os::raw::c_char, + async: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQgetline(conn: *mut PGconn, string: *mut ::std::os::raw::c_char, + length: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQputline(conn: *mut PGconn, string: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQgetlineAsync(conn: *mut PGconn, + buffer: *mut ::std::os::raw::c_char, + bufsize: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQputnbytes(conn: *mut PGconn, + buffer: *const ::std::os::raw::c_char, + nbytes: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQendcopy(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsetnonblocking(conn: *mut PGconn, arg: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQisnonblocking(conn: *const PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQisthreadsafe() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQping(conninfo: *const ::std::os::raw::c_char) -> PGPing; +} +extern "C" { + pub fn PQpingParams(keywords: *const *const ::std::os::raw::c_char, + values: *const *const ::std::os::raw::c_char, + expand_dbname: ::std::os::raw::c_int) -> PGPing; +} +extern "C" { + pub fn PQflush(conn: *mut PGconn) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQfn(conn: *mut PGconn, fnid: ::std::os::raw::c_int, + result_buf: *mut ::std::os::raw::c_int, + result_len: *mut ::std::os::raw::c_int, + result_is_int: ::std::os::raw::c_int, args: *const PQArgBlock, + nargs: ::std::os::raw::c_int) -> *mut PGresult; +} +extern "C" { + pub fn PQresultStatus(res: *const PGresult) -> ExecStatusType; +} +extern "C" { + pub fn PQresStatus(status: ExecStatusType) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQresultErrorMessage(res: *const PGresult) + -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQresultErrorField(res: *const PGresult, + fieldcode: ::std::os::raw::c_int) + -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQntuples(res: *const PGresult) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQnfields(res: *const PGresult) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQbinaryTuples(res: *const PGresult) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQfname(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQfnumber(res: *const PGresult, + field_name: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQftable(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> Oid; +} +extern "C" { + pub fn PQftablecol(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQfformat(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQftype(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> Oid; +} +extern "C" { + pub fn PQfsize(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQfmod(res: *const PGresult, field_num: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQcmdStatus(res: *mut PGresult) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQoidStatus(res: *const PGresult) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQoidValue(res: *const PGresult) -> Oid; +} +extern "C" { + pub fn PQcmdTuples(res: *mut PGresult) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQgetvalue(res: *const PGresult, tup_num: ::std::os::raw::c_int, + field_num: ::std::os::raw::c_int) + -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQgetlength(res: *const PGresult, tup_num: ::std::os::raw::c_int, + field_num: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQgetisnull(res: *const PGresult, tup_num: ::std::os::raw::c_int, + field_num: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQnparams(res: *const PGresult) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQparamtype(res: *const PGresult, param_num: ::std::os::raw::c_int) + -> Oid; +} +extern "C" { + pub fn PQdescribePrepared(conn: *mut PGconn, + stmt: *const ::std::os::raw::c_char) + -> *mut PGresult; +} +extern "C" { + pub fn PQdescribePortal(conn: *mut PGconn, + portal: *const ::std::os::raw::c_char) + -> *mut PGresult; +} +extern "C" { + pub fn PQsendDescribePrepared(conn: *mut PGconn, + stmt: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQsendDescribePortal(conn: *mut PGconn, + portal: *const ::std::os::raw::c_char) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQclear(res: *mut PGresult); +} +extern "C" { + pub fn PQfreemem(ptr: *mut ::std::os::raw::c_void); +} +extern "C" { + pub fn PQmakeEmptyPGresult(conn: *mut PGconn, status: ExecStatusType) + -> *mut PGresult; +} +extern "C" { + pub fn PQcopyResult(src: *const PGresult, flags: ::std::os::raw::c_int) + -> *mut PGresult; +} +extern "C" { + pub fn PQsetResultAttrs(res: *mut PGresult, + numAttributes: ::std::os::raw::c_int, + attDescs: *mut PGresAttDesc) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQresultAlloc(res: *mut PGresult, nBytes: usize) + -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn PQsetvalue(res: *mut PGresult, tup_num: ::std::os::raw::c_int, + field_num: ::std::os::raw::c_int, + value: *mut ::std::os::raw::c_char, + len: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQescapeStringConn(conn: *mut PGconn, + to: *mut ::std::os::raw::c_char, + from: *const ::std::os::raw::c_char, + length: usize, + error: *mut ::std::os::raw::c_int) -> usize; +} +extern "C" { + pub fn PQescapeLiteral(conn: *mut PGconn, + str: *const ::std::os::raw::c_char, len: usize) + -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQescapeIdentifier(conn: *mut PGconn, + str: *const ::std::os::raw::c_char, len: usize) + -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn PQescapeByteaConn(conn: *mut PGconn, + from: *const ::std::os::raw::c_uchar, + from_length: usize, to_length: *mut usize) + -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn PQunescapeBytea(strtext: *const ::std::os::raw::c_uchar, + retbuflen: *mut usize) + -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn PQescapeString(to: *mut ::std::os::raw::c_char, + from: *const ::std::os::raw::c_char, length: usize) + -> usize; +} +extern "C" { + pub fn PQescapeBytea(from: *const ::std::os::raw::c_uchar, + from_length: usize, to_length: *mut usize) + -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn PQprint(fout: *mut FILE, res: *const PGresult, + ps: *const PQprintOpt); +} +extern "C" { + pub fn PQdisplayTuples(res: *const PGresult, fp: *mut FILE, + fillAlign: ::std::os::raw::c_int, + fieldSep: *const ::std::os::raw::c_char, + printHeader: ::std::os::raw::c_int, + quiet: ::std::os::raw::c_int); +} +extern "C" { + pub fn PQprintTuples(res: *const PGresult, fout: *mut FILE, + printAttName: ::std::os::raw::c_int, + terseOutput: ::std::os::raw::c_int, + width: ::std::os::raw::c_int); +} +extern "C" { + pub fn PQlibVersion() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQmblen(s: *const ::std::os::raw::c_char, + encoding: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQdsplen(s: *const ::std::os::raw::c_char, + encoding: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQenv2encoding() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn PQencryptPassword(passwd: *const ::std::os::raw::c_char, + user: *const ::std::os::raw::c_char) + -> *mut ::std::os::raw::c_char; +} diff --git a/src/lib.rs b/src/lib.rs index 158cc50..e2bf380 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,905 +1,5 @@ -#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] +#[cfg(feature = "bundled")] +extern crate pq_src; -/* automatically generated by rust-bindgen */ - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -pub type __int64_t = ::std::os::raw::c_longlong; -pub type __darwin_size_t = ::std::os::raw::c_ulong; -pub type __darwin_off_t = __int64_t; -pub type fpos_t = __darwin_off_t; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct __sbuf { - pub _base: *mut ::std::os::raw::c_uchar, - pub _size: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout___sbuf() { - assert_eq!(::std::mem::size_of::<__sbuf>() , 16usize); - assert_eq!(::std::mem::align_of::<__sbuf>() , 8usize); -} -impl Clone for __sbuf { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __sFILEX([u8; 0]); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct __sFILE { - pub _p: *mut ::std::os::raw::c_uchar, - pub _r: ::std::os::raw::c_int, - pub _w: ::std::os::raw::c_int, - pub _flags: ::std::os::raw::c_short, - pub _file: ::std::os::raw::c_short, - pub _bf: __sbuf, - pub _lbfsize: ::std::os::raw::c_int, - pub _cookie: *mut ::std::os::raw::c_void, - pub _close: ::std::option::Option ::std::os::raw::c_int>, - pub _read: ::std::option::Option ::std::os::raw::c_int>, - pub _seek: ::std::option::Option ::std::os::raw::c_longlong>, - pub _write: ::std::option::Option ::std::os::raw::c_int>, - pub _ub: __sbuf, - pub _extra: *mut __sFILEX, - pub _ur: ::std::os::raw::c_int, - pub _ubuf: [::std::os::raw::c_uchar; 3usize], - pub _nbuf: [::std::os::raw::c_uchar; 1usize], - pub _lb: __sbuf, - pub _blksize: ::std::os::raw::c_int, - pub _offset: fpos_t, -} -#[test] -fn bindgen_test_layout___sFILE() { - assert_eq!(::std::mem::size_of::<__sFILE>() , 152usize); - assert_eq!(::std::mem::align_of::<__sFILE>() , 8usize); -} -impl Clone for __sFILE { - fn clone(&self) -> Self { *self } -} -pub type FILE = __sFILE; -pub type Oid = ::std::os::raw::c_uint; -pub const CONNECTION_OK: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_OK; -pub const CONNECTION_BAD: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_BAD; -pub const CONNECTION_STARTED: _bindgen_ty_2 = - _bindgen_ty_2::CONNECTION_STARTED; -pub const CONNECTION_MADE: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_MADE; -pub const CONNECTION_AWAITING_RESPONSE: _bindgen_ty_2 = - _bindgen_ty_2::CONNECTION_AWAITING_RESPONSE; -pub const CONNECTION_AUTH_OK: _bindgen_ty_2 = - _bindgen_ty_2::CONNECTION_AUTH_OK; -pub const CONNECTION_SETENV: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_SETENV; -pub const CONNECTION_SSL_STARTUP: _bindgen_ty_2 = - _bindgen_ty_2::CONNECTION_SSL_STARTUP; -pub const CONNECTION_NEEDED: _bindgen_ty_2 = _bindgen_ty_2::CONNECTION_NEEDED; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_2 { - CONNECTION_OK = 0, - CONNECTION_BAD = 1, - CONNECTION_STARTED = 2, - CONNECTION_MADE = 3, - CONNECTION_AWAITING_RESPONSE = 4, - CONNECTION_AUTH_OK = 5, - CONNECTION_SETENV = 6, - CONNECTION_SSL_STARTUP = 7, - CONNECTION_NEEDED = 8, -} -pub use self::_bindgen_ty_2 as ConnStatusType; -pub const PGRES_POLLING_FAILED: _bindgen_ty_3 = - _bindgen_ty_3::PGRES_POLLING_FAILED; -pub const PGRES_POLLING_READING: _bindgen_ty_3 = - _bindgen_ty_3::PGRES_POLLING_READING; -pub const PGRES_POLLING_WRITING: _bindgen_ty_3 = - _bindgen_ty_3::PGRES_POLLING_WRITING; -pub const PGRES_POLLING_OK: _bindgen_ty_3 = _bindgen_ty_3::PGRES_POLLING_OK; -pub const PGRES_POLLING_ACTIVE: _bindgen_ty_3 = - _bindgen_ty_3::PGRES_POLLING_ACTIVE; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_3 { - PGRES_POLLING_FAILED = 0, - PGRES_POLLING_READING = 1, - PGRES_POLLING_WRITING = 2, - PGRES_POLLING_OK = 3, - PGRES_POLLING_ACTIVE = 4, -} -pub use self::_bindgen_ty_3 as PostgresPollingStatusType; -pub const PGRES_EMPTY_QUERY: _bindgen_ty_4 = _bindgen_ty_4::PGRES_EMPTY_QUERY; -pub const PGRES_COMMAND_OK: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COMMAND_OK; -pub const PGRES_TUPLES_OK: _bindgen_ty_4 = _bindgen_ty_4::PGRES_TUPLES_OK; -pub const PGRES_COPY_OUT: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COPY_OUT; -pub const PGRES_COPY_IN: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COPY_IN; -pub const PGRES_BAD_RESPONSE: _bindgen_ty_4 = - _bindgen_ty_4::PGRES_BAD_RESPONSE; -pub const PGRES_NONFATAL_ERROR: _bindgen_ty_4 = - _bindgen_ty_4::PGRES_NONFATAL_ERROR; -pub const PGRES_FATAL_ERROR: _bindgen_ty_4 = _bindgen_ty_4::PGRES_FATAL_ERROR; -pub const PGRES_COPY_BOTH: _bindgen_ty_4 = _bindgen_ty_4::PGRES_COPY_BOTH; -pub const PGRES_SINGLE_TUPLE: _bindgen_ty_4 = - _bindgen_ty_4::PGRES_SINGLE_TUPLE; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_4 { - PGRES_EMPTY_QUERY = 0, - PGRES_COMMAND_OK = 1, - PGRES_TUPLES_OK = 2, - PGRES_COPY_OUT = 3, - PGRES_COPY_IN = 4, - PGRES_BAD_RESPONSE = 5, - PGRES_NONFATAL_ERROR = 6, - PGRES_FATAL_ERROR = 7, - PGRES_COPY_BOTH = 8, - PGRES_SINGLE_TUPLE = 9, -} -pub use self::_bindgen_ty_4 as ExecStatusType; -pub const PQTRANS_IDLE: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_IDLE; -pub const PQTRANS_ACTIVE: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_ACTIVE; -pub const PQTRANS_INTRANS: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_INTRANS; -pub const PQTRANS_INERROR: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_INERROR; -pub const PQTRANS_UNKNOWN: _bindgen_ty_5 = _bindgen_ty_5::PQTRANS_UNKNOWN; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_5 { - PQTRANS_IDLE = 0, - PQTRANS_ACTIVE = 1, - PQTRANS_INTRANS = 2, - PQTRANS_INERROR = 3, - PQTRANS_UNKNOWN = 4, -} -pub use self::_bindgen_ty_5 as PGTransactionStatusType; -pub const PQERRORS_TERSE: _bindgen_ty_6 = _bindgen_ty_6::PQERRORS_TERSE; -pub const PQERRORS_DEFAULT: _bindgen_ty_6 = _bindgen_ty_6::PQERRORS_DEFAULT; -pub const PQERRORS_VERBOSE: _bindgen_ty_6 = _bindgen_ty_6::PQERRORS_VERBOSE; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_6 { - PQERRORS_TERSE = 0, - PQERRORS_DEFAULT = 1, - PQERRORS_VERBOSE = 2, -} -pub use self::_bindgen_ty_6 as PGVerbosity; -pub const PQPING_OK: _bindgen_ty_7 = _bindgen_ty_7::PQPING_OK; -pub const PQPING_REJECT: _bindgen_ty_7 = _bindgen_ty_7::PQPING_REJECT; -pub const PQPING_NO_RESPONSE: _bindgen_ty_7 = - _bindgen_ty_7::PQPING_NO_RESPONSE; -pub const PQPING_NO_ATTEMPT: _bindgen_ty_7 = _bindgen_ty_7::PQPING_NO_ATTEMPT; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_7 { - PQPING_OK = 0, - PQPING_REJECT = 1, - PQPING_NO_RESPONSE = 2, - PQPING_NO_ATTEMPT = 3, -} -pub use self::_bindgen_ty_7 as PGPing; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct pg_conn([u8; 0]); -pub type PGconn = pg_conn; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct pg_result([u8; 0]); -pub type PGresult = pg_result; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct pg_cancel([u8; 0]); -pub type PGcancel = pg_cancel; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct pgNotify { - pub relname: *mut ::std::os::raw::c_char, - pub be_pid: ::std::os::raw::c_int, - pub extra: *mut ::std::os::raw::c_char, - pub next: *mut pgNotify, -} -#[test] -fn bindgen_test_layout_pgNotify() { - assert_eq!(::std::mem::size_of::() , 32usize); - assert_eq!(::std::mem::align_of::() , 8usize); -} -impl Clone for pgNotify { - fn clone(&self) -> Self { *self } -} -pub type PGnotify = pgNotify; -pub type PQnoticeReceiver = - ::std::option::Option; -pub type PQnoticeProcessor = - ::std::option::Option; -pub type pqbool = ::std::os::raw::c_char; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct _PQprintOpt { - pub header: pqbool, - pub align: pqbool, - pub standard: pqbool, - pub html3: pqbool, - pub expanded: pqbool, - pub pager: pqbool, - pub fieldSep: *mut ::std::os::raw::c_char, - pub tableOpt: *mut ::std::os::raw::c_char, - pub caption: *mut ::std::os::raw::c_char, - pub fieldName: *mut *mut ::std::os::raw::c_char, -} -#[test] -fn bindgen_test_layout__PQprintOpt() { - assert_eq!(::std::mem::size_of::<_PQprintOpt>() , 40usize); - assert_eq!(::std::mem::align_of::<_PQprintOpt>() , 8usize); -} -impl Clone for _PQprintOpt { - fn clone(&self) -> Self { *self } -} -pub type PQprintOpt = _PQprintOpt; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct _PQconninfoOption { - pub keyword: *mut ::std::os::raw::c_char, - pub envvar: *mut ::std::os::raw::c_char, - pub compiled: *mut ::std::os::raw::c_char, - pub val: *mut ::std::os::raw::c_char, - pub label: *mut ::std::os::raw::c_char, - pub dispchar: *mut ::std::os::raw::c_char, - pub dispsize: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout__PQconninfoOption() { - assert_eq!(::std::mem::size_of::<_PQconninfoOption>() , 56usize); - assert_eq!(::std::mem::align_of::<_PQconninfoOption>() , 8usize); -} -impl Clone for _PQconninfoOption { - fn clone(&self) -> Self { *self } -} -pub type PQconninfoOption = _PQconninfoOption; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct _bindgen_ty_8 { - pub len: ::std::os::raw::c_int, - pub isint: ::std::os::raw::c_int, - pub u: _bindgen_ty_8__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct _bindgen_ty_8__bindgen_ty_1 { - pub ptr: __BindgenUnionField<*mut ::std::os::raw::c_int>, - pub integer: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout__bindgen_ty_8__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_8__bindgen_ty_1>() , 8usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_8__bindgen_ty_1>() , - 8usize); -} -impl Clone for _bindgen_ty_8__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout__bindgen_ty_8() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_8>() , 16usize); - assert_eq!(::std::mem::align_of::<_bindgen_ty_8>() , 8usize); -} -impl Clone for _bindgen_ty_8 { - fn clone(&self) -> Self { *self } -} -pub type PQArgBlock = _bindgen_ty_8; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct pgresAttDesc { - pub name: *mut ::std::os::raw::c_char, - pub tableid: Oid, - pub columnid: ::std::os::raw::c_int, - pub format: ::std::os::raw::c_int, - pub typid: Oid, - pub typlen: ::std::os::raw::c_int, - pub atttypmod: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_pgresAttDesc() { - assert_eq!(::std::mem::size_of::() , 32usize); - assert_eq!(::std::mem::align_of::() , 8usize); -} -impl Clone for pgresAttDesc { - fn clone(&self) -> Self { *self } -} -pub type PGresAttDesc = pgresAttDesc; -extern "C" { - pub fn PQconnectStart(conninfo: *const ::std::os::raw::c_char) - -> *mut PGconn; -} -extern "C" { - pub fn PQconnectStartParams(keywords: - *const *const ::std::os::raw::c_char, - values: *const *const ::std::os::raw::c_char, - expand_dbname: ::std::os::raw::c_int) - -> *mut PGconn; -} -extern "C" { - pub fn PQconnectPoll(conn: *mut PGconn) -> PostgresPollingStatusType; -} -extern "C" { - pub fn PQconnectdb(conninfo: *const ::std::os::raw::c_char) - -> *mut PGconn; -} -extern "C" { - pub fn PQconnectdbParams(keywords: *const *const ::std::os::raw::c_char, - values: *const *const ::std::os::raw::c_char, - expand_dbname: ::std::os::raw::c_int) - -> *mut PGconn; -} -extern "C" { - pub fn PQsetdbLogin(pghost: *const ::std::os::raw::c_char, - pgport: *const ::std::os::raw::c_char, - pgoptions: *const ::std::os::raw::c_char, - pgtty: *const ::std::os::raw::c_char, - dbName: *const ::std::os::raw::c_char, - login: *const ::std::os::raw::c_char, - pwd: *const ::std::os::raw::c_char) -> *mut PGconn; -} -extern "C" { - pub fn PQfinish(conn: *mut PGconn); -} -extern "C" { - pub fn PQconndefaults() -> *mut PQconninfoOption; -} -extern "C" { - pub fn PQconninfoParse(conninfo: *const ::std::os::raw::c_char, - errmsg: *mut *mut ::std::os::raw::c_char) - -> *mut PQconninfoOption; -} -extern "C" { - pub fn PQconninfo(conn: *mut PGconn) -> *mut PQconninfoOption; -} -extern "C" { - pub fn PQconninfoFree(connOptions: *mut PQconninfoOption); -} -extern "C" { - pub fn PQresetStart(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQresetPoll(conn: *mut PGconn) -> PostgresPollingStatusType; -} -extern "C" { - pub fn PQreset(conn: *mut PGconn); -} -extern "C" { - pub fn PQgetCancel(conn: *mut PGconn) -> *mut PGcancel; -} -extern "C" { - pub fn PQfreeCancel(cancel: *mut PGcancel); -} -extern "C" { - pub fn PQcancel(cancel: *mut PGcancel, - errbuf: *mut ::std::os::raw::c_char, - errbufsize: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQrequestCancel(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQdb(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQuser(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQpass(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQhost(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQport(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQtty(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQoptions(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQstatus(conn: *const PGconn) -> ConnStatusType; -} -extern "C" { - pub fn PQtransactionStatus(conn: *const PGconn) - -> PGTransactionStatusType; -} -extern "C" { - pub fn PQparameterStatus(conn: *const PGconn, - paramName: *const ::std::os::raw::c_char) - -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn PQprotocolVersion(conn: *const PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQserverVersion(conn: *const PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQerrorMessage(conn: *const PGconn) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQsocket(conn: *const PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQbackendPID(conn: *const PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQconnectionNeedsPassword(conn: *const PGconn) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQconnectionUsedPassword(conn: *const PGconn) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQclientEncoding(conn: *const PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsetClientEncoding(conn: *mut PGconn, - encoding: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsslInUse(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsslStruct(conn: *mut PGconn, - struct_name: *const ::std::os::raw::c_char) - -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn PQsslAttribute(conn: *mut PGconn, - attribute_name: *const ::std::os::raw::c_char) - -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn PQsslAttributeNames(conn: *mut PGconn) - -> *const *const ::std::os::raw::c_char; -} -extern "C" { - pub fn PQgetssl(conn: *mut PGconn) -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn PQinitSSL(do_init: ::std::os::raw::c_int); -} -extern "C" { - pub fn PQinitOpenSSL(do_ssl: ::std::os::raw::c_int, - do_crypto: ::std::os::raw::c_int); -} -extern "C" { - pub fn PQsetErrorVerbosity(conn: *mut PGconn, verbosity: PGVerbosity) - -> PGVerbosity; -} -extern "C" { - pub fn PQtrace(conn: *mut PGconn, debug_port: *mut FILE); -} -extern "C" { - pub fn PQuntrace(conn: *mut PGconn); -} -extern "C" { - pub fn PQsetNoticeReceiver(conn: *mut PGconn, proc_: PQnoticeReceiver, - arg: *mut ::std::os::raw::c_void) - -> PQnoticeReceiver; -} -extern "C" { - pub fn PQsetNoticeProcessor(conn: *mut PGconn, proc_: PQnoticeProcessor, - arg: *mut ::std::os::raw::c_void) - -> PQnoticeProcessor; -} -pub type pgthreadlock_t = - ::std::option::Option; -extern "C" { - pub fn PQregisterThreadLock(newhandler: pgthreadlock_t) -> pgthreadlock_t; -} -extern "C" { - pub fn PQexec(conn: *mut PGconn, query: *const ::std::os::raw::c_char) - -> *mut PGresult; -} -extern "C" { - pub fn PQexecParams(conn: *mut PGconn, - command: *const ::std::os::raw::c_char, - nParams: ::std::os::raw::c_int, - paramTypes: *const Oid, - paramValues: *const *const ::std::os::raw::c_char, - paramLengths: *const ::std::os::raw::c_int, - paramFormats: *const ::std::os::raw::c_int, - resultFormat: ::std::os::raw::c_int) -> *mut PGresult; -} -extern "C" { - pub fn PQprepare(conn: *mut PGconn, - stmtName: *const ::std::os::raw::c_char, - query: *const ::std::os::raw::c_char, - nParams: ::std::os::raw::c_int, paramTypes: *const Oid) - -> *mut PGresult; -} -extern "C" { - pub fn PQexecPrepared(conn: *mut PGconn, - stmtName: *const ::std::os::raw::c_char, - nParams: ::std::os::raw::c_int, - paramValues: *const *const ::std::os::raw::c_char, - paramLengths: *const ::std::os::raw::c_int, - paramFormats: *const ::std::os::raw::c_int, - resultFormat: ::std::os::raw::c_int) - -> *mut PGresult; -} -extern "C" { - pub fn PQsendQuery(conn: *mut PGconn, - query: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsendQueryParams(conn: *mut PGconn, - command: *const ::std::os::raw::c_char, - nParams: ::std::os::raw::c_int, - paramTypes: *const Oid, - paramValues: - *const *const ::std::os::raw::c_char, - paramLengths: *const ::std::os::raw::c_int, - paramFormats: *const ::std::os::raw::c_int, - resultFormat: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsendPrepare(conn: *mut PGconn, - stmtName: *const ::std::os::raw::c_char, - query: *const ::std::os::raw::c_char, - nParams: ::std::os::raw::c_int, - paramTypes: *const Oid) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsendQueryPrepared(conn: *mut PGconn, - stmtName: *const ::std::os::raw::c_char, - nParams: ::std::os::raw::c_int, - paramValues: - *const *const ::std::os::raw::c_char, - paramLengths: *const ::std::os::raw::c_int, - paramFormats: *const ::std::os::raw::c_int, - resultFormat: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsetSingleRowMode(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQgetResult(conn: *mut PGconn) -> *mut PGresult; -} -extern "C" { - pub fn PQisBusy(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQconsumeInput(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQnotifies(conn: *mut PGconn) -> *mut PGnotify; -} -extern "C" { - pub fn PQputCopyData(conn: *mut PGconn, - buffer: *const ::std::os::raw::c_char, - nbytes: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQputCopyEnd(conn: *mut PGconn, - errormsg: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQgetCopyData(conn: *mut PGconn, - buffer: *mut *mut ::std::os::raw::c_char, - async: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQgetline(conn: *mut PGconn, string: *mut ::std::os::raw::c_char, - length: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQputline(conn: *mut PGconn, string: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQgetlineAsync(conn: *mut PGconn, - buffer: *mut ::std::os::raw::c_char, - bufsize: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQputnbytes(conn: *mut PGconn, - buffer: *const ::std::os::raw::c_char, - nbytes: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQendcopy(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsetnonblocking(conn: *mut PGconn, arg: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQisnonblocking(conn: *const PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQisthreadsafe() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQping(conninfo: *const ::std::os::raw::c_char) -> PGPing; -} -extern "C" { - pub fn PQpingParams(keywords: *const *const ::std::os::raw::c_char, - values: *const *const ::std::os::raw::c_char, - expand_dbname: ::std::os::raw::c_int) -> PGPing; -} -extern "C" { - pub fn PQflush(conn: *mut PGconn) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQfn(conn: *mut PGconn, fnid: ::std::os::raw::c_int, - result_buf: *mut ::std::os::raw::c_int, - result_len: *mut ::std::os::raw::c_int, - result_is_int: ::std::os::raw::c_int, args: *const PQArgBlock, - nargs: ::std::os::raw::c_int) -> *mut PGresult; -} -extern "C" { - pub fn PQresultStatus(res: *const PGresult) -> ExecStatusType; -} -extern "C" { - pub fn PQresStatus(status: ExecStatusType) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQresultErrorMessage(res: *const PGresult) - -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQresultErrorField(res: *const PGresult, - fieldcode: ::std::os::raw::c_int) - -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQntuples(res: *const PGresult) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQnfields(res: *const PGresult) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQbinaryTuples(res: *const PGresult) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQfname(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQfnumber(res: *const PGresult, - field_name: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQftable(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> Oid; -} -extern "C" { - pub fn PQftablecol(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQfformat(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQftype(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> Oid; -} -extern "C" { - pub fn PQfsize(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQfmod(res: *const PGresult, field_num: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQcmdStatus(res: *mut PGresult) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQoidStatus(res: *const PGresult) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQoidValue(res: *const PGresult) -> Oid; -} -extern "C" { - pub fn PQcmdTuples(res: *mut PGresult) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQgetvalue(res: *const PGresult, tup_num: ::std::os::raw::c_int, - field_num: ::std::os::raw::c_int) - -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQgetlength(res: *const PGresult, tup_num: ::std::os::raw::c_int, - field_num: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQgetisnull(res: *const PGresult, tup_num: ::std::os::raw::c_int, - field_num: ::std::os::raw::c_int) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQnparams(res: *const PGresult) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQparamtype(res: *const PGresult, param_num: ::std::os::raw::c_int) - -> Oid; -} -extern "C" { - pub fn PQdescribePrepared(conn: *mut PGconn, - stmt: *const ::std::os::raw::c_char) - -> *mut PGresult; -} -extern "C" { - pub fn PQdescribePortal(conn: *mut PGconn, - portal: *const ::std::os::raw::c_char) - -> *mut PGresult; -} -extern "C" { - pub fn PQsendDescribePrepared(conn: *mut PGconn, - stmt: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQsendDescribePortal(conn: *mut PGconn, - portal: *const ::std::os::raw::c_char) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQclear(res: *mut PGresult); -} -extern "C" { - pub fn PQfreemem(ptr: *mut ::std::os::raw::c_void); -} -extern "C" { - pub fn PQmakeEmptyPGresult(conn: *mut PGconn, status: ExecStatusType) - -> *mut PGresult; -} -extern "C" { - pub fn PQcopyResult(src: *const PGresult, flags: ::std::os::raw::c_int) - -> *mut PGresult; -} -extern "C" { - pub fn PQsetResultAttrs(res: *mut PGresult, - numAttributes: ::std::os::raw::c_int, - attDescs: *mut PGresAttDesc) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQresultAlloc(res: *mut PGresult, nBytes: usize) - -> *mut ::std::os::raw::c_void; -} -extern "C" { - pub fn PQsetvalue(res: *mut PGresult, tup_num: ::std::os::raw::c_int, - field_num: ::std::os::raw::c_int, - value: *mut ::std::os::raw::c_char, - len: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQescapeStringConn(conn: *mut PGconn, - to: *mut ::std::os::raw::c_char, - from: *const ::std::os::raw::c_char, - length: usize, - error: *mut ::std::os::raw::c_int) -> usize; -} -extern "C" { - pub fn PQescapeLiteral(conn: *mut PGconn, - str: *const ::std::os::raw::c_char, len: usize) - -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQescapeIdentifier(conn: *mut PGconn, - str: *const ::std::os::raw::c_char, len: usize) - -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn PQescapeByteaConn(conn: *mut PGconn, - from: *const ::std::os::raw::c_uchar, - from_length: usize, to_length: *mut usize) - -> *mut ::std::os::raw::c_uchar; -} -extern "C" { - pub fn PQunescapeBytea(strtext: *const ::std::os::raw::c_uchar, - retbuflen: *mut usize) - -> *mut ::std::os::raw::c_uchar; -} -extern "C" { - pub fn PQescapeString(to: *mut ::std::os::raw::c_char, - from: *const ::std::os::raw::c_char, length: usize) - -> usize; -} -extern "C" { - pub fn PQescapeBytea(from: *const ::std::os::raw::c_uchar, - from_length: usize, to_length: *mut usize) - -> *mut ::std::os::raw::c_uchar; -} -extern "C" { - pub fn PQprint(fout: *mut FILE, res: *const PGresult, - ps: *const PQprintOpt); -} -extern "C" { - pub fn PQdisplayTuples(res: *const PGresult, fp: *mut FILE, - fillAlign: ::std::os::raw::c_int, - fieldSep: *const ::std::os::raw::c_char, - printHeader: ::std::os::raw::c_int, - quiet: ::std::os::raw::c_int); -} -extern "C" { - pub fn PQprintTuples(res: *const PGresult, fout: *mut FILE, - printAttName: ::std::os::raw::c_int, - terseOutput: ::std::os::raw::c_int, - width: ::std::os::raw::c_int); -} -extern "C" { - pub fn PQlibVersion() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQmblen(s: *const ::std::os::raw::c_char, - encoding: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQdsplen(s: *const ::std::os::raw::c_char, - encoding: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQenv2encoding() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn PQencryptPassword(passwd: *const ::std::os::raw::c_char, - user: *const ::std::os::raw::c_char) - -> *mut ::std::os::raw::c_char; -} +mod bindings; +pub use bindings::*;