Skip to content

pg_wildcard

Wildcard and regex telemetry search with an Antalya foreign data wrapper

pg_wildcard · Wildcard and regex telemetry search with an Antalya foreign data wrapper

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102431pg_wildcardpg_wildcard0.2.3FTSApache-2.0Rust

PostgreSQL · 18, 19

Usage

Sources:

pg_wildcard 0.2.3 searches telemetry strings with wildcard and regular-expression predicates, derives indicators and generates ClickHouse/Antalya queries. It also supplies the scan-only wildcard_fdw. The published crate uses antalya-rs 0.1.1; PostgreSQL 18 and 19 are qualified server majors. Declared PostgreSQL 14–17 build features require separate qualification.

A superuser installs this untrusted, non-relocatable extension. No shared preload or server restart is documented for ordinary use.

CREATE EXTENSION pg_wildcard;
SELECT wc_match('https://example.org/admin', '*/admin', 'raw');
SELECT wc_match('GET /%77p-ADMIN/a.PHP', '*/wp-admin/*.php', 'decoded');
SELECT * FROM wc_indicator('hxxps://Login.Evil[.]com/');
SELECT wc_explain('*/wp-admin/*.php', 'wildcard', 'decoded');

Views include raw, lower, decoded, revdomain and winpath. wc_match, wc_like and wc_regex match text; wc_regex_bytes handles bytes. wc_url_decode preserves decoded bytes, while wc_view produces display text. wc_explain describes conservative candidates; an exact predicate must still decide the match. Regex semantics follow the supported RE2 dialect.

Remote Queries and Lake Metadata

wc_ch_predicate and related helpers return SQL for the caller to execute. Their optional filter expressions are trusted SQL fragments. wc_lake_index, wc_lake_file and wc_lake_gram hold imported pruning metadata; candidate files always require an exact recheck, and missing coverage must widen the scan.

wildcard_fdw requires an Antalya endpoint, a user mapping with bearer_token, compatible scalar columns and a UTF-8 PostgreSQL database. Generic ClickHouse HTTP availability is insufficient. The mapping principal needs source access and the documented query-completion evidence, normally from system.query_log. Protect mapping credentials and refresh tokens separately.

The wrapper pushes supported predicates but retains local checks. Joins and aggregates stay local; foreign tables have no local PostgreSQL index. Unsupported collation or query shapes limit pushdown. A late remote or completion error fails the statement even after some rows have been streamed.

Resource Limits and Upgrades

pg_wildcard.matcher_cache_entries and pg_wildcard.matcher_cache_kb bound retained patterns per backend; wc_matcher_cache_stats() reports this cache. These limits do not cap total backend memory.

From 0.2.0, 0.2.1 or 0.2.2, install the matching 0.2.3 library and SQL files, reconnect, then run:

ALTER EXTENSION pg_wildcard UPDATE TO '0.2.3';

The update preserves SQL signatures and records the new extension version. Standalone library, lake CLI and remote-engine configuration are separate components.

Optional batching and staged sweeps run outside the FDW; callers own execution, admission limits and cleanup. The FDW does not automatically parallelize queries, and compression is not exposed as a production FDW option.

Table reader