Skip to content

pgs3 reference

Complete lookup for pgs3 v0.1.2: server GUCs, S3 API compatibility subset, SQL functions, and SQLSTATE-to-S3 error mappings.

Server configuration (GUCs)

All nine pgs3.* parameters have SIGHUP context, though some changes only take effect for new requests or require a restart as noted below.

pgs3.enabled , boolean , defaultoff
Register the static launcher on server startup when pgs3 is in shared_preload_libraries. Dynamic pgs3.start() ignores this flag.
pgs3.workers , integer (1–64) , default4
Desired number of HTTP background workers. Each consumes one max_worker_processes slot.
pgs3.listen_addr , string (IP) , default127.0.0.1
IPv4 or IPv6 bind address for HTTP workers. Keep on loopback and terminate TLS in a reverse proxy.
pgs3.port , integer (1–65535) , default9000
Shared SO_REUSEPORT TCP port for HTTP workers.
pgs3.inline_threshold , integer (bytes, 0–1 GiB) , default65536
Largest physical blob stored inline in pgs3.blob for new writes. Direct single-transaction PUT has an additional 64 KiB cap.
pgs3.chunk_size , integer (bytes, 64 KiB–16 MiB) , default4194304
Chunk size for staged uploads exceeding the inline threshold; snapshotted per upload on admission.
pgs3.statement_timeout_ms , integer (ms, 1–3600000) , default30000
PostgreSQL statement/lock timeout for each SPI semantic transaction. Applies to new transactions.
pgs3.target_database , string , defaultpostgres
Database served by the preloaded static launcher. Changing the pool’s database requires a server restart.
pgs3.server_role , string , defaultpgs3_server
Restricted service identity used by HTTP workers. Custom roles must exist beforehand and be NOLOGIN NOINHERIT with no elevated attributes, no inbound members, and SET-only membership in tenant roles.

Inspect live values

SELECT name, setting, unit, context, source, pending_restart
FROM pg_settings
WHERE name LIKE 'pgs3.%'
ORDER BY name;

Reload vs. restart

  • Applies on SIGHUP reload: pgs3.workers, pgs3.listen_addr, pgs3.port, pgs3.statement_timeout_ms, pgs3.inline_threshold (new blobs), and pgs3.chunk_size (new uploads). Existing blobs keep their original physical layout. Always verify a real signed request after a port/address rebind because a failed bind can keep the old listener running.
  • Requires a server restart: Adding pgs3 to shared_preload_libraries, changing pgs3.enabled from off to on when the static launcher was not registered at boot, or changing pgs3.target_database.
  • Service role changes: Reconciling a changed pgs3.server_role on reload requires matching grants and lacks release acceptance testing; prefer a planned restart.

Fixed implementation thresholds

These limits are built into v0.1.2 and have no registered GUC:

  • Upload lease: 5 minutes; body-idle timeout: 60 seconds (renewed on subsequent body progress).
  • Pending upload retention: 24 hours; GC interval: every 60 seconds, up to 1,000 rows per batch.
  • SQL hash fallback limit: Optional pgs3.sql_hash_fallback_limit custom setting defaults to 134217728 bytes (128 MiB); packaged builds use Rust hash helpers instead.

S3 API compatibility

AreaSupported APIsBehavior and boundaries
BucketsListBuckets, CreateBucket, DeleteBucket, HeadBucket, GetBucketLocation, GetBucketVersioningVersioning is permanently Enabled. DeleteBucket requires an empty bucket (including historical versions); pending uploads alone are aborted atomically on delete.
ObjectsPutObject, GetObject, HeadObject, CopyObject, DeleteObject, DeleteObjectsSupports single Range, If-Match/If-None-Match/date conditions, x-amz-meta-* metadata, source versionId copies, and SHA-256 / MD5 / flexible checksums. DeleteObjects accepts up to 1,000 keys per batch.
ListingListObjects (V1), ListObjectsV2, ListObjectVersionsPrefix, delimiter, encoding-type=url, max-keys (0–1000), V1 markers, and V2 continuation tokens.
MultipartCreateMultipartUpload, UploadPart, ListParts, CompleteMultipartUpload, AbortMultipartUploadNon-final parts must be ≥ 5 MiB. UploadPartCopy and ListMultipartUploads are not supported.
Version restorePOST /{bucket}/{key}?restore&versionId={id}pgs3 extension route that publishes an older version as the new latest version (not AWS Glacier archival restore).

Signing and unsupported features

  • Supported auth: Header-based AWS SigV4 (FullHash, UNSIGNED-PAYLOAD, STREAMING-AWS4-HMAC-SHA256-PAYLOAD, STREAMING-UNSIGNED-PAYLOAD-TRAILER) and query-parameter presigned GET/PUT URLs (max expiry 7 days, clock skew ±15 minutes).
  • Outside the subset: Virtual-host bucket addressing, TLS termination, bucket policies, ACLs, CORS, object tagging, lifecycle/TTL rules, object lock/retention, multi-range GET, UploadPartCopy, and ListMultipartUploads.

SQL API

Tenant operations run under the caller’s PostgreSQL role (with RLS isolation); operator functions are revoked from PUBLIC.

Buckets and objects

pgs3.create_bucket(p_name text, p_config jsonb) , bucket_info , defaultp_config = '{}'
Create a bucket owned by the current role (idempotent for the same owner).
pgs3.list_buckets() , setof bucket_info , default—
List buckets visible to the current role.
pgs3.delete_bucket(p_name text) , boolean , default—
Delete an empty bucket (aborts leftover pending uploads).
pgs3.put(p_bucket text, p_key text, p_body bytea, p_content_type text, p_meta jsonb, p_if_none_match text, p_if_match text, p_checksum_sha256 bytea) , object_info , default'application/octet-stream', '{}', NULL, NULL, NULL
Atomically write a new object version; supports ETag preconditions and SHA-256 verification.
pgs3.head(p_bucket text, p_key text, p_version_id bigint, p_if_match text, p_if_none_match text) , object_info , defaultNULL, NULL, NULL
Read object metadata for the latest or specified version.
pgs3.get(p_bucket text, p_key text, p_version_id bigint, p_if_match text, p_if_none_match text) , object_data , defaultNULL, NULL, NULL
Read object metadata and full body bytea.
pgs3.get_range(p_bucket text, p_key text, p_start bigint, p_end bigint, p_version_id bigint, p_if_match text, p_if_none_match text) , bytea , defaultNULL, NULL, NULL, NULL
Read an inclusive 0-based byte slice of an object.
pgs3.copy(p_source_bucket text, p_source_key text, p_destination_bucket text, p_destination_key text, p_source_version_id bigint, p_content_type text, p_meta jsonb, p_if_none_match text, p_if_match text, p_source_if_match text) , object_info , defaultNULL for optional params
Copy an object or version by sharing its canonical SHA-256 blob.
pgs3.delete(p_bucket text, p_key text, p_version_id bigint) , delete_result , defaultp_version_id = NULL
Insert a delete marker when p_version_id is NULL, or permanently delete that version.
pgs3.list(p_bucket text, p_prefix text, p_delimiter text, p_start_after text, p_continuation_token text, p_max_keys integer) , setof list_entry , default'', NULL, NULL, NULL, 1000
List keys and common prefixes in indexed key order.
pgs3.restore(p_bucket text, p_key text, p_version_id bigint, p_if_match text) , object_info , defaultp_if_match = NULL
Publish a historical version’s payload as a new latest version.
pgs3.fork_bucket(p_source_bucket text, p_destination_bucket text, p_destination_config jsonb) , bigint , defaultp_destination_config = NULL
Create a new bucket sharing the source’s latest blobs and return the number of entries copied.

Credentials and runtime operations

pgs3.create_credential(p_access_key text, p_secret text, p_role_name name, p_enabled boolean) , boolean , defaultp_enabled = true
Operator only. Create an S3 key pair bound to an unprivileged tenant role.
pgs3.rotate_credential(p_access_key text, p_new_secret text) , boolean , default—
Operator only. Replace the signing secret for an existing key.
pgs3.set_credential_role(p_access_key text, p_role_name name) , boolean , default—
Operator only. Reassign an access key to another unprivileged tenant role.
pgs3.set_credential_enabled(p_access_key text, p_enabled boolean) , boolean , default—
Operator only. Suspend or re-enable an access key.
pgs3.delete_credential(p_access_key text) , boolean , default—
Operator only. Delete an access key.
pgs3.start() , boolean , default—
Operator only. Start a dynamic worker pool for the current database.
pgs3.stop() , boolean , default—
Operator only. Stop the dynamic worker pool in the current database.
pgs3.extension_version() , text , default—
Return the installed SQL catalog version of pgs3.
pgs3.worker_state , table , default—
Live launcher, GC, and HTTP worker status, listener address, and heartbeats.
pgs3.stats , view , default—
Aggregated HTTP request counters, errors, latency buckets, bytes, and GC/upload backlog.
pgs3.gc_pending_uploads(p_max_age interval, p_limit integer) , bigint , default—
Operator only. Clean up expired pending uploads in bounded batches.
pgs3.gc_blobs(p_limit integer) , bigint , default1000
Operator only. Delete unreferenced zero-refcount blobs in bounded batches.

SQLSTATE to S3 error mapping

SQLSTATEHTTPS3 error code
P3B01404NoSuchBucket
P3K01404NoSuchKey / NoSuchVersion
P3U01404NoSuchUpload
P3C01412PreconditionFailed
P3N01304NotModified (no XML body)
P3R01416InvalidRange
P3E01409BucketAlreadyExists
P3F01409BucketNotEmpty
P3H01400BadDigest
P3P01400InvalidPart / InvalidPartOrder / EntityTooSmall
P3S01400EntityTooLarge
42501403AccessDenied
25006503ServiceUnavailable (read-only standby)
57014503SlowDown (statement timeout)
0A000501NotImplemented
other500InternalError

An allowlisted pgs3.error=<code> diagnostic detail takes precedence to distinguish finer variants such as NoSuchVersion, InvalidBucketName, or EntityTooSmall. HEAD and 304 responses omit XML bodies. For the complete protocol-to-SQL mapping, see api-sql-mapping.md.