You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-6Lines changed: 48 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ pgrollback keeps **one real PostgreSQL transaction** on the server side and expo
43
43
- Connection pools and multiple connections per test ID.
44
44
- Automatic rollback when the session ends; no extra cleanup scripts.
45
45
- Real PostgreSQL execution (not mocked SQL).
46
-
-Optional web GUI for queries on the same listen port.
46
+
-Web GUI to view the running queries and query history.
47
47
48
48
---
49
49
@@ -68,10 +68,44 @@ When the test finishes (or you issue a full rollback command), the sandbox is di
68
68
69
69
## Quick start
70
70
71
-
1.**Install Go** (1.23+) and, on Windows for this repo, a **64-bit MinGW** toolchain for CGO (see [Build](#build)).
72
-
2.**Config** — Copy `config/pgrollback.yaml` and set `postgres.*` and `proxy.listen_*` for your machine.
73
-
3.**Run the proxy** — `make run` or `./bin/pgrollback --config config/pgrollback.yaml` (Windows: `build.bat` / `run.bat` after `setEnvironments.bat`).
74
-
4.**Point tests at the proxy** — Use the proxy host/port as the DB endpoint and set `application_name` to `pgrollback_<testID>` so sessions are isolated (see below).
71
+
This is how you **use** pgrollback: run the proxy, aim your app at it, and keep each test run in its own sandbox.
72
+
73
+
### From a release (binary)
74
+
75
+
1.**Download** the pgrollback for your platform from **[pgrollback releases](https://github.com/asfixia/pgrollback/releases/)**, plus the **sample config** (or use [`config/pgrollback.yaml`](config/pgrollback.yaml) from this repository).
76
+
77
+
2.**Point the proxy at your database** — In the YAML, set the `postgres` block to the credentials of the PostgreSQL instance you use for **testing** (the real server the proxy will open the long-lived transaction on):
78
+
79
+
```yaml
80
+
postgres:
81
+
host: localhost
82
+
port: 5432
83
+
database: postgres
84
+
user: postgres
85
+
password: postgres
86
+
```
87
+
88
+
Replace `host`, `port`, `database`, `user`, and `password` with your testing database. Your application does **not** connect here; only the proxy does.
89
+
90
+
3. **Change where the proxy listens** — Under `proxy`, keep or adjust `listen_host` and `listen_port`. For example:
91
+
92
+
```yaml
93
+
proxy:
94
+
listen_host: localhost
95
+
listen_port: 5433
96
+
```
97
+
98
+
Your app and tests will use **this** host and port as the “database” address.
99
+
100
+
4. **Start pgrollback** — Run the binary with your config, e.g. `./bin/pgrollback --config /path/to/pgrollback.yaml`.
101
+
102
+
5. **Configure your connection through the proxy** — Configure your PostgreSQL client to use `listen_host` and `listen_port` (e.g. `localhost` and `5433`). Traffic goes: **app → pgrollback → Postgres**. Work for that sandbox runs inside **one** server-side transaction; when the sandbox ends, it **rolls back**—no durable commits from that path.
103
+
104
+
6. **Separate sandboxes with `application_name`** — Set `application_name` to a stable value per logical test or worker, e.g. `pgrollback_<testId>`. The proxy treats each **distinct** `application_name` as a **different** sandbox (a **different** base transaction). Connections that share the same `application_name` share one sandbox; different names are isolated from each other. See [Connect from tests](#connect-from-tests).
105
+
106
+
### Building from source
107
+
108
+
To compile locally (Go, and on Windows MinGW for CGO), see [Build](#build). Then run the proxy the same way as in step 4, pointing `--config` at your edited YAML.
75
109
76
110
---
77
111
@@ -126,12 +160,20 @@ Example: `db.Exec("pgrollback rollback")` in Go, or the equivalent in your stack
126
160
127
161
**Windows:** install a **64-bit MinGW** GCC (e.g. MSYS2: `pacman -S mingw-w64-x86_64-gcc`), then run **`setEnvironments.bat`** so `PATH`, `CC`, `CXX`, and `CGO_ENABLED=1` are set. See `.vscode/settings.json` for terminal integration.
128
162
163
+
**Single-file Windows executable (default):** On Windows, **`build.bat`**, **`make build`**, **`make test`**, and **`test.bat`** all use **`CGO_LDFLAGS=-static`** so MinGW links the pthread/GCC runtime into the binary. The resulting `pgrollback.exe` typically only depends on system DLLs (`KERNEL32.dll`, `msvcrt.dll`)—no `libwinpthread-1.dll` next to the exe. Test binaries under `%TEMP%` also avoid needing MinGW on `PATH` at run time.
164
+
165
+
**Dynamic MinGW link (one flag):** **`build.bat dynamic`** or **`make build DYNAMIC=1`** (and **`make test DYNAMIC=1`** if you use Make for tests) skip `-static` for faster links; then keep MinGW’s `bin` on `PATH` at run time, or copy `libwinpthread-1.dll` / `libgcc_s_seh-1.dll` next to the exe (`build.bat dynamic` copies them into `bin\`). A plain **`go build`** outside these scripts does not set `-static`; pass **`CGO_LDFLAGS=-static`** yourself if you want a single-file exe.
166
+
129
167
```bash
130
168
go build -o bin/pgrollback ./cmd/pgrollback
131
-
# or
169
+
# or (Windows: static CGO by default)
132
170
make build
171
+
# or (Windows: dynamic CGO, faster link)
172
+
make build DYNAMIC=1
133
173
```
134
174
175
+
**CI:** On tag pushes, [`.github/workflows/ci.yml`](.github/workflows/ci.yml) builds Windows artifacts with **`CGO_LDFLAGS=-static`** (native `windows-latest` job and the Linux cross-compile job), consistent with the default local Windows build.
176
+
135
177
Without a proper 64-bit `gcc`, you may see errors like `sorry, unimplemented: 64-bit mode not compiled in`.
Copy file name to clipboardExpand all lines: internal/proxy/gui/handlers.go
+8-5Lines changed: 8 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,12 @@ import (
8
8
"pgrollback/internal/config"
9
9
)
10
10
11
-
// ConfigResponse is the config returned by GET /api/config (includes masked password and config_path).
11
+
// ConfigResponse is the config returned by GET /api/config.
12
+
// PostgresConnectionStringMasked is always derived from the same in-memory postgres settings as the proxy (via config.PostgresConnStringMasked), not stored separately.
0 commit comments