pgdsn

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package pgdsn builds libpq keyword/value connection strings.

It exists so the quoting rule has one implementation. Two subsystems hand a DSN to DuckDB's postgres scanner — internal/cdc (ATTACH, for CDC export) and internal/federated (postgres_scan, for the federated read path) — and an unquoted value is two bugs at once: a password containing a space produces a DSN libpq cannot parse, and the credential scrubber in internal/redact cannot tell where an unquoted value ends, so it truncates at the first separator and leaks the tail (#301).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(p Params) string

Build renders a libpq keyword/value DSN with every string value quoted, so values containing spaces or quotes survive parsing by pgx and by DuckDB's postgres scanner.

func Quote

func Quote(v string) string

Quote wraps a value in single quotes, escaping backslashes and single quotes with a backslash as libpq requires.

The escaping order matters: backslashes first, then quotes, so the backslash introduced for an escaped quote is not itself doubled.

Types

type Params

type Params struct {
	Host     string
	Port     int
	User     string
	Password string
	DB       string
	SSLMode  string
}

Params are the inputs for a libpq keyword/value connection string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL