Skip to content

aoc

Bigint product aggregate for Advent of Code SQL puzzles

adventofcode · Bigint product aggregate for Advent of Code SQL puzzles

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102475aocadventofcode1.0FUNCSQL

Usage

Sources:

aoc 1.0 is the extension used by this repository’s Advent of Code 2026 PostgreSQL solutions. Its installed SQL defines a product(bigint) aggregate; the C library contains module metadata. The reviewed source has no published release, explicit PostgreSQL-major compatibility list or license grant.

Aggregate workflow

After installing the source’s extension files, enable it as an administrator:

CREATE EXTENSION aoc;
SELECT product(value)
FROM (VALUES (2::bigint), (3::bigint), (4::bigint)) AS input(value);

The result is 24. The aggregate uses the built-in bigint multiplication function for transition and parallel combination. It retains bigint arithmetic limits and can overflow. There is no initial state, so an empty input produces NULL.

The extension is relocatable and does not require preload or restart. Qualify product with the installation schema when that schema is absent from the search path.

Puzzle scripts

The day-one script creates temporary input and frequency tables, then multiplies the three most or least frequent input values. Its server-side COPY reads a file path and needs the corresponding server file-read privileges. This file access belongs to the puzzle script, not to the aggregate itself.

The Makefile’s puzzle targets recreate the extension with DROP EXTENSION CASCADE. Run those targets only in a disposable puzzle database; they can remove objects that depend on the extension. The aggregate can be used directly without running those targets.

Table reader