Functions

AionDB implements a growing set of scalar functions. This page lists the main user-facing families.

Function compatibility should be tested by behavior, not only by name. PostgreSQL has many edge cases around nulls, encodings, regex flags, timezone rules, formatting strings, and implicit casts.

Text functions

Common text functions include:

Example:

SELECT lower(name), length(name)
FROM users;

Useful text checks:

SELECT upper('aiondb');
SELECT substring('abcdef' FROM 2 FOR 3);
SELECT replace('a-b-c', '-', '_');
SELECT concat_ws('/', 'docs', 'query', 'functions');

Test null handling if the application depends on PostgreSQL-equivalent behavior.

Regular expression functions

The text function registry includes PostgreSQL-style regular expression helpers such as:

Regex behavior is compatibility-sensitive. Test flags and edge cases against your expected PostgreSQL behavior.

Recommended regex fixture:

SELECT regexp_replace('abc123', '[0-9]+', 'N');
SELECT regexp_match('abc123', '([a-z]+)([0-9]+)');

Date and time functions

Common date/time functions include:

Date/time functions are among the most compatibility-sensitive surfaces. Validate timezone, precision, formatting, and transaction timestamp expectations with your driver.

Useful checks:

SELECT current_date;
SELECT date_part('year', current_timestamp);
SELECT date_trunc('day', current_timestamp);

Vector functions

SELECT l2_distance(embedding, '[1.0,0.0,0.0]') FROM items;
SELECT cosine_distance(embedding, '[1.0,0.0,0.0]') FROM items;

Vector functions require matching dimensions.

Keep a tiny deterministic fixture:

CREATE TABLE vector_fn_demo (
    id INT,
    embedding VECTOR(2)
);

INSERT INTO vector_fn_demo VALUES
    (1, '[0.0,0.0]'),
    (2, '[1.0,0.0]');

SELECT id, l2_distance(embedding, '[1.0,0.0]') AS dist
FROM vector_fn_demo
ORDER BY dist ASC;

Compatibility functions

AionDB includes PostgreSQL-facing helper functions used by drivers, catalog queries, and compatibility paths. Treat those as implementation compatibility, not as a complete PostgreSQL extension surface.

Reporting function gaps

Function bug reports should include: