### Install PostgreSQL with Custom Configure Options Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs PostgreSQL with additional custom options passed to the configure script. ```bash POSTGRES_EXTRA_CONFIGURE_OPTIONS="--with-python" mise install postgres@17.2 ``` -------------------------------- ### Start PostgreSQL Server Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Starts the PostgreSQL server using pg_ctl, specifying the data directory and a log file. ```bash pg_ctl -D $PGDATA -l logfile start ``` -------------------------------- ### Install PostgreSQL Skipping initdb Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs a PostgreSQL version while skipping the automatic database cluster initialization. ```bash POSTGRES_SKIP_INITDB=1 mise install postgres@17.2 ``` -------------------------------- ### Install PostgreSQL with vfox Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Adds the PostgreSQL plugin to vfox and installs the latest available version. ```bash vfox add postgres vfox install postgres@latest ``` -------------------------------- ### Compile and Install PostgreSQL from Source Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Compiles and installs PostgreSQL from source, builds contrib modules, and initializes the database cluster. Requires execution of shell commands. ```lua --- Compiles and installs PostgreSQL from source --- @param ctx PostInstallCtx Context provided by vfox function PLUGIN:PostInstall(ctx) local sdkInfo = ctx.sdkInfo["postgres"] local version = sdkInfo.version local sdkPath = sdkInfo.path -- Build configure options with platform-specific paths local configureOptions = "--prefix=" .. sdkPath .. " --with-openssl --with-zlib" -- Run: ./configure && make -j$(nproc) && make install os.execute("cd " .. sdkPath .. " && ./configure " .. configureOptions) os.execute("cd " .. sdkPath .. " && make -j$(nproc)") os.execute("cd " .. sdkPath .. " && make install") -- Build contrib modules os.execute("cd " .. sdkPath .. "/contrib && make && make install") -- Initialize database cluster local dataDir = sdkPath .. "/data" os.execute("mkdir -p " .. dataDir) os.execute(sdkPath .. "/bin/initdb -D " .. dataDir .. " -U postgres") end ``` -------------------------------- ### Install PostgreSQL with mise Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs PostgreSQL versions using the mise package manager. Supports installing the latest available version or specific versions. ```bash mise install postgres@latest mise install postgres@17.2 mise install postgres@16.6 ``` -------------------------------- ### Install PostgreSQL with vfox Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Add the postgres plugin to vfox and install PostgreSQL versions. This is an alternative to using mise for version management. ```bash vfox add postgres ``` ```bash vfox install postgres@latest ``` ```bash vfox install postgres@17.2 ``` -------------------------------- ### Install macOS Dependencies Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs necessary dependencies for PostgreSQL compilation on macOS using Homebrew. ```bash xcode-select --install brew install openssl readline ``` -------------------------------- ### Install RHEL/CentOS Dependencies Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs development tools and libraries for PostgreSQL compilation on RHEL/CentOS systems. ```bash sudo yum groupinstall "Development Tools" sudo yum install readline-devel zlib-devel openssl-devel uuid-devel ``` -------------------------------- ### Install Debian/Ubuntu Dependencies Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs required build tools and libraries for PostgreSQL compilation on Debian/Ubuntu systems. ```bash sudo apt-get install build-essential libreadline-dev zlib1g-dev libssl-dev uuid-dev ``` -------------------------------- ### Install PostgreSQL Overriding Configure Options Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs PostgreSQL by completely overriding the default configure options, ensuring only the specified options are used. ```bash POSTGRES_CONFIGURE_OPTIONS="--with-openssl --with-python" mise install postgres@17.2 ``` -------------------------------- ### List Available PostgreSQL Versions Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Lists all remote PostgreSQL versions available for installation using mise. ```bash mise ls-remote postgres ``` -------------------------------- ### Connect to PostgreSQL Database Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Connect to a running PostgreSQL instance using the psql client. Examples show connecting as the default user, to a specific database, and executing a query directly. ```bash # Connect to the database psql -U postgres # Connect to a specific database psql -U postgres -d mydb # Execute a query directly psql -U postgres -c "SELECT version();" ``` -------------------------------- ### Install PostgreSQL Build Dependencies Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Install the necessary system packages required for compiling PostgreSQL from source on different operating systems. This ensures all build tools and libraries are available. ```bash # macOS - Install Xcode tools and Homebrew packages xcode-select --install brew install openssl readline # Optional: Install ICU and UUID support brew install icu4c ossp-uuid # Debian/Ubuntu sudo apt-get install build-essential libreadline-dev zlib1g-dev libssl-dev uuid-dev # Optional: Install ICU support sudo apt-get install libicu-dev # RHEL/CentOS sudo yum groupinstall "Development Tools" sudo yum install readline-devel zlib-devel openssl-devel uuid-devel ``` -------------------------------- ### Run PostgreSQL in Foreground Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Starts the PostgreSQL server process in the foreground, useful for debugging or running in specific environments. ```bash postgres -D $PGDATA ``` -------------------------------- ### Manage PostgreSQL Server Lifecycle Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Control the PostgreSQL server process using standard PostgreSQL commands. This includes starting, checking status, and stopping the server. ```bash # Start PostgreSQL server in background pg_ctl -D $PGDATA -l logfile start # Check server status pg_ctl -D $PGDATA status # Start in foreground (useful for debugging) postgres -D $PGDATA # Stop the server pg_ctl -D $PGDATA stop ``` -------------------------------- ### Custom OpenSSL Location for PostgreSQL Build Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Specify a custom OpenSSL installation path using OPENSSL_ROOT_DIR or OPENSSL_DIR. This is useful when using non-standard OpenSSL installations, particularly on macOS. ```bash # Use MacPorts OpenSSL OPENSSL_ROOT_DIR="/opt/local/libexec/openssl3" mise install postgres@17.2 # Use custom compiled OpenSSL OPENSSL_DIR="/usr/local/custom-openssl" mise install postgres@17.2 ``` -------------------------------- ### Get PostgreSQL Download URL Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Returns the download URL for the PostgreSQL source tarball based on the provided version. Used in the PreInstall hook. ```lua --- Returns pre-install information for PostgreSQL --- @param ctx table Context provided by vfox --- @return table Pre-install info with version and download URL function PLUGIN:PreInstall(ctx) local version = ctx.version return { version = version, url = "https://ftp.postgresql.org/pub/source/v" .. version .. "/postgresql-" .. version .. ".tar.gz", } end -- Example: For version 17.2, returns: -- { -- version = "17.2", -- url = "https://ftp.postgresql.org/pub/source/v17.2/postgresql-17.2.tar.gz" -- } ``` -------------------------------- ### Set PostgreSQL Environment Variables Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Sets environment variables for the active PostgreSQL installation, including PATH and PGDATA. Adds LD_LIBRARY_PATH on Linux. ```lua --- Returns environment variables for PostgreSQL --- @param ctx table Context provided by vfox --- @return table Environment configuration function PLUGIN:EnvKeys(ctx) local sdkInfo = ctx.sdkInfo["postgres"] local installDir = sdkInfo.path local envs = { { key = "PATH", value = installDir .. "/bin" }, { key = "PGDATA", value = installDir .. "/data" }, } -- Add LD_LIBRARY_PATH on Linux if RUNTIME.osType == "linux" then table.insert(envs, { key = "LD_LIBRARY_PATH", value = installDir .. "/lib", }) end return envs end ``` -------------------------------- ### Override OpenSSL Location on macOS Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Installs PostgreSQL specifying a custom location for OpenSSL on macOS, useful when OpenSSL is not in a standard path. ```bash OPENSSL_ROOT_DIR="/opt/local/libexec/openssl3" mise install postgres@17.2 ``` -------------------------------- ### Set Local PostgreSQL Version Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Sets the local PostgreSQL version for the current project and creates a .mise.toml configuration file. ```bash mise use postgres@17.2 ``` -------------------------------- ### Connect to PostgreSQL Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Connects to the PostgreSQL database using the psql client as the 'postgres' user. ```bash psql -U postgres ``` -------------------------------- ### Fetch PostgreSQL Versions Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Fetches all available PostgreSQL versions by parsing the HTML directory listing from the official FTP server. Requires the 'http' module. ```lua --- Returns all available PostgreSQL versions from the official FTP server --- @param ctx table Context provided by vfox --- @return table Available versions function PLUGIN:Available(ctx) local http = require("http") local resp, err = http.get({ url = "https://ftp.postgresql.org/pub/source/", }) if err ~= nil then error("Failed to fetch PostgreSQL versions: " .. err) end -- Parse HTML: >v17.2/<, >v16.6/<, >v9.6.24/< local result = {} for version in string.gmatch(resp.body, ">v([0-9]+%.[0-9]+[%.0-9]*)/<" ) do table.insert(result, { version = version }) end return result end ``` -------------------------------- ### Environment Variables Set by Plugin Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Understand the environment variables automatically configured by the plugin after activating a PostgreSQL version. These are crucial for the system to locate PostgreSQL binaries and data. ```bash # After activating a PostgreSQL version, these are set: echo $PATH # Includes {install_path}/bin echo $PGDATA # Points to {install_path}/data # On Linux only: echo $LD_LIBRARY_PATH # Includes {install_path}/lib ``` -------------------------------- ### Custom Configure Options for PostgreSQL Build Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Extend the default PostgreSQL build configuration by providing additional flags via POSTGRES_EXTRA_CONFIGURE_OPTIONS. This allows enabling optional features during compilation. ```bash # Add Python support to the default options POSTGRES_EXTRA_CONFIGURE_OPTIONS="--with-python" mise install postgres@17.2 # Add multiple extra options POSTGRES_EXTRA_CONFIGURE_OPTIONS="--with-python --with-perl --with-tcl" mise install postgres@17.2 ``` -------------------------------- ### Override PostgreSQL Configure Options Source: https://context7.com/mise-plugins/vfox-postgres/llms.txt Completely replace the default PostgreSQL configure options (except --prefix) using POSTGRES_CONFIGURE_OPTIONS. This provides full control over the build process. ```bash # Completely override configure options POSTGRES_CONFIGURE_OPTIONS="--with-openssl --with-python --with-perl" mise install postgres@17.2 # Minimal build without optional features POSTGRES_CONFIGURE_OPTIONS="--without-icu --without-readline" mise install postgres@17.2 ``` -------------------------------- ### Set Global PostgreSQL Version Source: https://github.com/mise-plugins/vfox-postgres/blob/main/README.md Sets the globally active PostgreSQL version using mise. ```bash mise use -g postgres@17.2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.