pg_testgen
pg_testgen · Generate random integers, strings, and test-data rows for PostgreSQL development
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101098 | pg_testgen | pg_testgen | 1.0 | FUNC | Unknown | C |
Usage
Sources:
pg_testgen generates random integers and alphanumeric text, either as scalar values or set-returning functions. It is intended to populate development and test tables quickly, not to generate credentials, security tokens, or statistically rigorous samples.
Core Workflow
The example inserts 5,000 rows: integer values are in the inclusive range [1, 100], and strings contain 20 to 30 ASCII letters or digits.
Object Index
rand_int()returns a nonnegative 32-bit-range random integer.rand_int(a, b)returns an integer in inclusive range[a, b].rand_text(),rand_text(length), andrand_text(min_length, max_length)return random ASCII alphanumeric text.rows_int(count [, min, max])returnscountrandom integers.rows_text(count [, length])androws_text(count, min_length, max_length)returncountrandom strings.
Operational Notes
Version 1.0 declares no extension dependency or preload requirement. The implementation uses the C library rand() with modulo arithmetic; it is not cryptographically secure, does not promise independent backend seeding, and can be biased. Never use it for passwords, keys, identifiers that require uniqueness, or benchmark-quality distributions.
Validate arguments in the caller. The C code does not safely reject a reversed/overflowing integer range, negative text length, or invalid row count; such inputs can cause errors or unsafe allocation behavior. For large data sets, batch inserts and monitor WAL, table size, indexes, and transaction duration.