diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2ac4769..39af2c6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,9 +19,9 @@ jobs: strategy: fail-fast: false # We want all of them to run, even if one fails matrix: - os: [ "buildjet-4vcpu-ubuntu-2204" ] - pg: [ "13", "14", "15", "16", "17" ] - + os: ["buildjet-4vcpu-ubuntu-2204"] + pg: ["13", "14", "15", "16", "17", "18"] + runs-on: ${{ matrix.os }} env: RUSTC_WRAPPER: sccache @@ -54,11 +54,10 @@ jobs: brew install postgresql@${{ matrix.pg_version }} echo "/usr/local/opt/postgresql@${{ matrix.pg_version }}/bin" >> $GITHUB_PATH - - name: Set up prerequisites and environment run: | sudo apt-get update -y -qq --fix-missing - + echo "" echo "----- Install sccache -----" mkdir -p $HOME/.local/bin @@ -68,11 +67,11 @@ jobs: echo "$HOME/.local/bin" >> $GITHUB_PATH mkdir -p /home/runner/.cache/sccache echo "" - + echo "----- Set up dynamic variables -----" cat $GITHUB_ENV echo "" - + echo "----- Install system dependencies -----" sudo apt-get install -y \ build-essential \ @@ -88,7 +87,7 @@ jobs: echo "----- Print env -----" env echo "" - + - name: Cache cargo registry uses: actions/cache@v4 continue-on-error: false @@ -118,7 +117,7 @@ jobs: cargo pgrx init --pg${{ matrix.pg }} /usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config - name: Run tests run: echo "\q" | cargo pgrx run pg${{ matrix.pg }} && cargo test --no-default-features --features pg${{ matrix.pg }} - + - name: Build run: cargo pgrx package --features pg${{ matrix.pg }} --pg-config /usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config @@ -148,8 +147,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - os: [ "buildjet-4vcpu-ubuntu-2204" ] - pg: [ "16" ] + os: ["buildjet-4vcpu-ubuntu-2204"] + pg: ["16"] steps: - uses: actions/checkout@v4 @@ -201,4 +200,4 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Run rustfmt - run: cargo fmt -- --check \ No newline at end of file + run: cargo fmt -- --check diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0269263..42007e8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,7 @@ name: Build • Publish • Release # We still build + release when a tag like v1.2.3 is pushed on: push: - tags: ['v*'] + tags: ["v*"] permissions: contents: write @@ -12,10 +12,9 @@ permissions: env: EXTENSION_NAME: typeid - DOCKER_IMAGE: ghcr.io/blitss/typeid-pg + DOCKER_IMAGE: ghcr.io/blitss/typeid-pg jobs: - # ------------------------------------------------------------- # 1. Build binaries for every PG version / OS / arch # ------------------------------------------------------------- @@ -23,10 +22,13 @@ jobs: strategy: fail-fast: false matrix: - pg_version: [13, 14, 15, 16, 17] - os: [buildjet-4vcpu-ubuntu-2204, - buildjet-4vcpu-ubuntu-2204-arm, - macos-latest] + pg_version: [13, 14, 15, 16, 17, 18] + os: + [ + buildjet-4vcpu-ubuntu-2204, + buildjet-4vcpu-ubuntu-2204-arm, + macos-latest, + ] runs-on: ${{ matrix.os }} @@ -38,7 +40,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable - override: true + override: true # --- PostgreSQL (Linux) ------------------------------------------ - name: Install PostgreSQL (Linux) @@ -114,7 +116,6 @@ jobs: path: release/*.tar.gz retention-days: 29 - # ------------------------------------------------------------- # 2. Build & push the multi-arch Docker image # ------------------------------------------------------------- @@ -124,7 +125,7 @@ jobs: strategy: fail-fast: false matrix: - pg_version: [13, 14, 15, 16, 17] + pg_version: [13, 14, 15, 16, 17, 18] steps: - uses: actions/checkout@v4 @@ -149,21 +150,20 @@ jobs: images: ${{ env.DOCKER_IMAGE }} tags: | type=raw,value=${{ matrix.pg_version }} - type=raw,value=latest,enable=${{ matrix.pg_version == 17 }} - type=raw,value=${{ github.ref_name }},enable=${{ matrix.pg_version == 17 }} + type=raw,value=latest,enable=${{ matrix.pg_version == 18 }} + type=raw,value=${{ github.ref_name }},enable=${{ matrix.pg_version == 18 }} - name: Build & push uses: docker/build-push-action@v4 with: context: . - push: true + push: true platforms: linux/amd64,linux/arm64 build-args: | PG_VERSION=${{ matrix.pg_version }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # ------------------------------------------------------------- # 3. Draft / publish the GitHub Release # ------------------------------------------------------------- @@ -171,8 +171,8 @@ jobs: needs: [build-and-publish] runs-on: ubuntu-latest permissions: - contents: write # create / update the release - packages: write # attach artifacts + contents: write # create / update the release + packages: write # attach artifacts steps: - uses: actions/checkout@v4 with: @@ -193,9 +193,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag: ${{ github.ref_name }} # the tag we just pushed - publish: false # keep as draft for now - prerelease: false # we'll flip below + tag: ${{ github.ref_name }} # the tag we just pushed + publish: false # keep as draft for now + prerelease: false # we'll flip below config-name: release-drafter.yml # --- 3-c. Flip logic: ONLY "main" ⇒ final ------------------------ @@ -213,11 +213,11 @@ jobs: - name: Publish GitHub Release uses: softprops/action-gh-release@v2 with: - name: ${{ steps.notes.outputs.name }} - tag_name: ${{ steps.notes.outputs.tag_name }} - body: ${{ steps.notes.outputs.body }} + name: ${{ steps.notes.outputs.name }} + tag_name: ${{ steps.notes.outputs.tag_name }} + body: ${{ steps.notes.outputs.body }} prerelease: ${{ steps.prerelease.outputs.is_pre }} - draft: false + draft: false files: | release/*.tar.gz env: diff --git a/.github/workflows/test-migrations.yaml b/.github/workflows/test-migrations.yaml index 6050521..f097e4f 100644 --- a/.github/workflows/test-migrations.yaml +++ b/.github/workflows/test-migrations.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + - name: Install PostgreSQL run: | sudo apt-get update @@ -24,19 +24,19 @@ jobs: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update -y -qq --fix-missing sudo apt-get install postgresql-16 postgresql-server-dev-16 - - - name: Install v0.1.0 + + - name: Install previous latest version run: | # Install.sh will by default install the latest stable release that we'll need to test against. sudo bash install.sh - + - name: Start PostgreSQL and create test database run: | sudo systemctl start postgresql.service sudo -u postgres createuser -s -d -r -w runner createdb -U runner test_extension - - - name: Install v0.1.0 and create test data + + - name: Create test data run: | psql -U runner -d test_extension -c "CREATE EXTENSION typeid;" psql -U runner -d test_extension -c " @@ -48,31 +48,30 @@ jobs: # Verify v0.1.0 works psql -U runner -d test_extension -c "SELECT COUNT(*) FROM migration_test;" psql -U runner -d test_extension -c "SELECT typeid_generate('user') FROM migration_test;" - - + - name: Install cargo-pgrx run: | PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version') cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force cargo pgrx init --pg16 $(which pg_config) - + - name: Install latest version and test migration run: | # Build the new version and install cargo pgrx package --features pg16 --pg-config $(which pg_config) cargo pgrx install --features pg16 --release --sudo - + # Perform the migration psql -U runner -d test_extension -c "ALTER EXTENSION typeid UPDATE;" psql -U runner -d test_extension -c "SELECT extversion FROM pg_extension WHERE extname = 'typeid';" - + # Verify old data still works psql -U runner -d test_extension -c "SELECT COUNT(*) FROM migration_test;" psql -U runner -d test_extension -c "SELECT typeid_prefix(id) FROM migration_test;" - + # Test new functions # todo: should extract that to a test sql file psql -U runner -d test_extension -c "SELECT typeid_generate_nil();" psql -U runner -d test_extension -c "SELECT typeid_is_valid('user_01h455vb4pex5vsknk084sn02q');" psql -U runner -d test_extension -c "SELECT COUNT(*) FROM migration_test WHERE id @> 'user';" - psql -U runner -d test_extension -c "SELECT typeid_has_prefix(typeid_generate('test'), 'test');" \ No newline at end of file + psql -U runner -d test_extension -c "SELECT typeid_has_prefix(typeid_generate('test'), 'test');" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cb765c5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "rust-analyzer.cargo.features": [ + "pg17" + ], + "rust-analyzer.cargo.noDefaultFeatures": true +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 04c1cb7..86924c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "typeid" -version = "0.2.0" +version = "0.3.0" edition = "2021" [lib] @@ -11,23 +11,24 @@ name = "pgrx_embed_typeid" path = "./src/bin/pgrx_embed.rs" [features] -default = ["pg17"] +default = ["pg18"] pg13 = ["pgrx/pg13", "pgrx-tests/pg13" ] pg14 = ["pgrx/pg14", "pgrx-tests/pg14" ] pg15 = ["pgrx/pg15", "pgrx-tests/pg15" ] pg16 = ["pgrx/pg16", "pgrx-tests/pg16" ] pg17 = ["pgrx/pg17", "pgrx-tests/pg17" ] +pg18 = ["pgrx/pg18", "pgrx-tests/pg18" ] pg_test = [] [dependencies] gxhash = { version = "3.5.0" } -pgrx = "=0.15.0" -serde = "1.0.219" -thiserror = "2.0.12" -uuid = { version = "1.17", features = ["v7", "fast-rng", "serde"] } +pgrx = "=0.16.1" +serde = "1.0.228" +thiserror = "2.0.17" +uuid = { version = "1.18", features = ["v7", "fast-rng", "serde"] } [dev-dependencies] -pgrx-tests = "=0.15.0" +pgrx-tests = "=0.16.1" serde_yaml = "0.9" libtest-mimic = "0.8" diff --git a/Dockerfile b/Dockerfile index 65b56bb..bdbb587 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG PG_VERSION=16 +ARG PG_VERSION=18 FROM postgres:${PG_VERSION} RUN apt update && apt install -y curl diff --git a/LICENSE b/LICENSE index 0fbf2a0..a9ad8e5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Andrew Vasilyev +Copyright (c) 2025 Andrew Vasilyev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Readme.md b/Readme.md index b7b799f..7fb3444 100644 --- a/Readme.md +++ b/Readme.md @@ -60,7 +60,7 @@ curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/refs/heads/ma Or you can specify the pg_config directly: ```bash -curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/refs/heads/main/install.sh | sudo bash -s -- /usr/pgsql-16/bin/pg_config +curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/refs/heads/main/install.sh | sudo bash -s -- /usr/pgsql-18/bin/pg_config ``` You can upgrade the same way and then run `ALTER EXTENSION typeid UPDATE;` in your Postgres database to run migration scripts. @@ -68,7 +68,7 @@ You can upgrade the same way and then run `ALTER EXTENSION typeid UPDATE;` in yo 3) By building extension manually Prerequisites: -* Postgres 13.x-17.x installed (probably from your package manager), including the "-server" package +* Postgres 13.x-18.x installed (probably from your package manager), including the "-server" package * The Rust toolchain @@ -76,14 +76,14 @@ Prerequisites: Windows is not supported due to pgrx limitations. -Run these commands (replace pg13 with your pg version and `which pg_config` part with your pg path if necessary): +Run these commands (replace pg18 with your pg version and `which pg_config` part with your pg path if necessary): ```bash git clone https://github.com/blitss/typeid-postgres-extension.git cd typeid-postgres-extension cargo install cargo-pgx -cargo pgx init --pg13=`which pg_config` +cargo pgx init --pg18=`which pg_config` cargo pgx install --release --sudo ``` diff --git a/sql/typeid--0.2.0--0.3.0.sql b/sql/typeid--0.2.0--0.3.0.sql new file mode 100644 index 0000000..ff309b1 --- /dev/null +++ b/sql/typeid--0.2.0--0.3.0.sql @@ -0,0 +1,3 @@ +/* +nothing changed in terms of schema +*/ \ No newline at end of file diff --git a/sql/typeid--0.3.0.sql b/sql/typeid--0.3.0.sql new file mode 100644 index 0000000..71952bc --- /dev/null +++ b/sql/typeid--0.3.0.sql @@ -0,0 +1,440 @@ +/* */ +/* +This file is auto generated by pgrx. + +The ordering of items is not stable, it is driven by a dependency graph. +*/ +/* */ + +/* */ +-- src/typeid.rs:107 +-- typeid::typeid::TypeID +CREATE TYPE TypeID; + +-- src/typeid.rs:107 +-- typeid::typeid::typeid_in +CREATE FUNCTION "typeid_in"( + "input" cstring /* core::option::Option<&core::ffi::c_str::CStr> */ +) RETURNS TypeID /* core::option::Option */ +IMMUTABLE PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_in_wrapper'; + +-- src/typeid.rs:107 +-- typeid::typeid::typeid_out +CREATE FUNCTION "typeid_out"( + "input" TypeID /* typeid::typeid::TypeID */ +) RETURNS cstring /* alloc::ffi::c_str::CString */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_out_wrapper'; + +-- src/typeid.rs:107 +-- typeid::typeid::typeid_recv +CREATE FUNCTION "typeid_recv"( + "internal" internal /* pgrx::datum::internal::Internal */ +) RETURNS TypeID /* typeid::typeid::TypeID */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_recv_wrapper'; + +-- src/typeid.rs:107 +-- typeid::typeid::typeid_send +CREATE FUNCTION "typeid_send"( + "input" TypeID /* typeid::typeid::TypeID */ +) RETURNS bytea /* alloc::vec::Vec */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_send_wrapper'; + + +-- src/typeid.rs:107 +-- typeid::typeid::TypeID +CREATE TYPE TypeID ( + INTERNALLENGTH = variable, + INPUT = typeid_in, /* typeid::typeid::typeid_in */ + OUTPUT = typeid_out, /* typeid::typeid::typeid_out */ + RECEIVE = typeid_recv, /* typeid::typeid::typeid_recv */ + SEND = typeid_send, /* typeid::typeid::typeid_send */ + STORAGE = extended +); +/* */ + +/* */ +-- src/aggregate.rs:42 +-- typeid::aggregate::type_id_max_type_id_max_combine +CREATE FUNCTION "type_id_max_type_id_max_combine"( + "this" TypeID, /* core::option::Option */ + "v" TypeID /* core::option::Option */ +) RETURNS TypeID /* core::option::Option */ +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'type_id_max_type_id_max_combine_wrapper'; +/* */ + +/* */ +-- src/aggregate.rs:42 +-- typeid::aggregate::type_id_max_type_id_max_state +CREATE FUNCTION "type_id_max_type_id_max_state"( + "this" TypeID, /* core::option::Option */ + "arg_one" TypeID /* typeid::typeid::TypeID */ +) RETURNS TypeID /* core::option::Option */ +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'type_id_max_type_id_max_state_wrapper'; +/* */ + +/* */ +-- src/aggregate.rs:12 +-- typeid::aggregate::type_id_min_type_id_min_combine +CREATE FUNCTION "type_id_min_type_id_min_combine"( + "this" TypeID, /* core::option::Option */ + "v" TypeID /* core::option::Option */ +) RETURNS TypeID /* core::option::Option */ +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'type_id_min_type_id_min_combine_wrapper'; +/* */ + +/* */ +-- src/aggregate.rs:12 +-- typeid::aggregate::type_id_min_type_id_min_state +CREATE FUNCTION "type_id_min_type_id_min_state"( + "this" TypeID, /* core::option::Option */ + "arg_one" TypeID /* typeid::typeid::TypeID */ +) RETURNS TypeID /* core::option::Option */ +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'type_id_min_type_id_min_state_wrapper'; +/* */ + +/* */ +-- src/lib.rs:93 +-- typeid::typeid_cmp +CREATE FUNCTION "typeid_cmp"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS INT /* i32 */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_cmp_wrapper'; +/* */ + +/* */ +-- src/lib.rs:108 +-- typeid::typeid_eq +CREATE FUNCTION "typeid_eq"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_eq_wrapper'; +/* */ + +/* */ +-- src/lib.rs:113 +-- typeid::typeid_ge +CREATE FUNCTION "typeid_ge"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_ge_wrapper'; +/* */ + +/* */ +-- src/lib.rs:31 +-- typeid::typeid_generate +CREATE FUNCTION "typeid_generate"( + "prefix" TEXT /* &str */ +) RETURNS TypeID /* typeid::typeid::TypeID */ +STRICT VOLATILE PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_generate_wrapper'; +/* */ + +/* */ +-- src/lib.rs:521 +-- typeid::typeid_generate_batch +CREATE FUNCTION "typeid_generate_batch"( + "prefix" TEXT, /* &str */ + "count" INT /* i32 */ +) RETURNS TypeID[] /* alloc::vec::Vec */ +STRICT VOLATILE PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_generate_batch_wrapper'; +/* */ + +/* */ +-- src/lib.rs:48 +-- typeid::typeid_generate_nil +CREATE FUNCTION "typeid_generate_nil"() RETURNS TypeID /* typeid::typeid::TypeID */ +STRICT VOLATILE PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_generate_nil_wrapper'; +/* */ + +/* */ +-- src/lib.rs:118 +-- typeid::typeid_gt +CREATE FUNCTION "typeid_gt"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_gt_wrapper'; +/* */ + +/* */ +-- src/lib.rs:497 +-- typeid::typeid_has_prefix +CREATE FUNCTION "typeid_has_prefix"( + "typeid" TypeID, /* typeid::typeid::TypeID */ + "prefix" TEXT /* &str */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_has_prefix_wrapper'; +/* */ + +/* */ +-- src/lib.rs:129 +-- typeid::typeid_hash +CREATE FUNCTION "typeid_hash"( + "typeid" TypeID /* typeid::typeid::TypeID */ +) RETURNS INT /* i32 */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_hash_wrapper'; +/* */ + +/* */ +-- src/lib.rs:136 +-- typeid::typeid_hash_extended +CREATE FUNCTION "typeid_hash_extended"( + "typeid" TypeID, /* typeid::typeid::TypeID */ + "seed" bigint /* i64 */ +) RETURNS bigint /* i64 */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_hash_extended_wrapper'; +/* */ + +/* */ +-- src/lib.rs:509 +-- typeid::typeid_is_nil_prefix +CREATE FUNCTION "typeid_is_nil_prefix"( + "typeid" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_is_nil_prefix_wrapper'; +/* */ + +/* */ +-- src/lib.rs:60 +-- typeid::typeid_is_valid +CREATE FUNCTION "typeid_is_valid"( + "input" TEXT /* &str */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_is_valid_wrapper'; +/* */ + +/* */ +-- src/lib.rs:103 +-- typeid::typeid_le +CREATE FUNCTION "typeid_le"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_le_wrapper'; +/* */ + +/* */ +-- src/lib.rs:98 +-- typeid::typeid_lt +CREATE FUNCTION "typeid_lt"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_lt_wrapper'; +/* */ + +/* */ +-- src/lib.rs:123 +-- typeid::typeid_ne +CREATE FUNCTION "typeid_ne"( + "a" TypeID, /* typeid::typeid::TypeID */ + "b" TypeID /* typeid::typeid::TypeID */ +) RETURNS bool /* bool */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_ne_wrapper'; +/* */ + +/* */ +-- src/lib.rs:66 +-- typeid::typeid_prefix +CREATE FUNCTION "typeid_prefix"( + "typeid" TypeID /* typeid::typeid::TypeID */ +) RETURNS TEXT /* alloc::string::String */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_prefix_wrapper'; +/* */ + +/* */ +-- src/lib.rs:72 +-- typeid::typeid_to_uuid +CREATE FUNCTION "typeid_to_uuid"( + "typeid" TypeID /* typeid::typeid::TypeID */ +) RETURNS uuid /* pgrx::datum::uuid::Uuid */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_to_uuid_wrapper'; +/* */ + +/* */ +-- src/lib.rs:144 +-- typeid::typeid_uuid_generate_v7 +CREATE FUNCTION "typeid_uuid_generate_v7"() RETURNS uuid /* pgrx::datum::uuid::Uuid */ +STRICT +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'typeid_uuid_generate_v7_wrapper'; +/* */ + +/* */ +-- src/lib.rs:77 +-- typeid::uuid_to_typeid +CREATE FUNCTION "uuid_to_typeid"( + "prefix" TEXT, /* &str */ + "uuid" uuid /* pgrx::datum::uuid::Uuid */ +) RETURNS TypeID /* typeid::typeid::TypeID */ +IMMUTABLE STRICT PARALLEL SAFE +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'uuid_to_typeid_wrapper'; +/* */ + +/* */ +-- src/aggregate.rs:42 +-- typeid::aggregate::TypeIDMax +CREATE AGGREGATE max ( + TypeID /* typeid::typeid::TypeID */ +) +( + SFUNC = "type_id_max_type_id_max_state", /* typeid::aggregate::TypeIDMax::state */ + STYPE = TypeID, /* core::option::Option */ + COMBINEFUNC = "type_id_max_type_id_max_combine", /* typeid::aggregate::TypeIDMax::combine */ + PARALLEL = SAFE /* typeid::aggregate::TypeIDMax::PARALLEL */ +); +/* */ + +/* */ +-- src/aggregate.rs:12 +-- typeid::aggregate::TypeIDMin +CREATE AGGREGATE min ( + TypeID /* typeid::typeid::TypeID */ +) +( + SFUNC = "type_id_min_type_id_min_state", /* typeid::aggregate::TypeIDMin::state */ + STYPE = TypeID, /* core::option::Option */ + COMBINEFUNC = "type_id_min_type_id_min_combine", /* typeid::aggregate::TypeIDMin::combine */ + PARALLEL = SAFE /* typeid::aggregate::TypeIDMin::PARALLEL */ +); +/* */ + +/* */ +-- src/lib.rs:149 +-- finalize + +/* ────────────────────────────────────────────────────────────── + * Implicit cast: text → typeid + * Allows: SELECT 'user_01h…' = id; + * Context: IMPLICIT (works everywhere a typeid is expected) + * Safety: relies on typeid_in for validation; bad literals + * still fail with ERROR. + * ──────────────────────────────────────────────────────────────*/ +CREATE CAST (text AS typeid) + WITH INOUT + AS IMPLICIT; + +/* ────────────────────────────────────────────────────────────── + * Additional utility functions for better SQL integration + * ──────────────────────────────────────────────────────────────*/ + +-- Create an operator for prefix matching to enable efficient queries +CREATE OPERATOR @> ( + LEFTARG = typeid, + RIGHTARG = text, + PROCEDURE = typeid_has_prefix, + COMMUTATOR = '@<' +); + +-- Create a functional index helper for prefix-based queries +-- Usage: CREATE INDEX idx_user_ids ON users (typeid_prefix(id)) WHERE typeid_has_prefix(id, 'user'); +COMMENT ON FUNCTION typeid_prefix(typeid) IS 'Extract the prefix from a TypeID for indexing and filtering'; +COMMENT ON FUNCTION typeid_has_prefix(typeid, text) IS 'Check if TypeID has a specific prefix - useful for filtering'; +COMMENT ON FUNCTION typeid_is_valid(text) IS 'Validate TypeID format without parsing - useful for constraints'; +COMMENT ON FUNCTION typeid_generate_nil() IS 'Generate TypeID with empty prefix (UUID-only format)'; + + CREATE OPERATOR < ( + LEFTARG = typeid, + RIGHTARG = typeid, + PROCEDURE = typeid_lt + ); + + CREATE OPERATOR <= ( + LEFTARG = typeid, + RIGHTARG = typeid, + PROCEDURE = typeid_le + ); + + CREATE OPERATOR = ( + LEFTARG = typeid, + RIGHTARG = typeid, + PROCEDURE = typeid_eq, + COMMUTATOR = '=', + NEGATOR = '<>', + HASHES, + MERGES + ); + + CREATE OPERATOR >= ( + LEFTARG = typeid, + RIGHTARG = typeid, + PROCEDURE = typeid_ge + ); + + CREATE OPERATOR > ( + LEFTARG = typeid, + RIGHTARG = typeid, + PROCEDURE = typeid_gt + ); + + CREATE OPERATOR <> ( + LEFTARG = typeid, + RIGHTARG = typeid, + PROCEDURE = typeid_ne + ); + + CREATE OPERATOR CLASS typeid_ops DEFAULT FOR TYPE typeid USING btree AS + OPERATOR 1 < (typeid, typeid), + OPERATOR 2 <= (typeid, typeid), + OPERATOR 3 = (typeid, typeid), + OPERATOR 4 >= (typeid, typeid), + OPERATOR 5 > (typeid, typeid), + FUNCTION 1 typeid_cmp(typeid, typeid); + + CREATE OPERATOR FAMILY typeid_hash_ops USING hash; + + CREATE OPERATOR CLASS typeid_hash_ops DEFAULT FOR TYPE typeid USING hash AS + OPERATOR 1 = (typeid, typeid), + FUNCTION 1 typeid_hash(typeid), + FUNCTION 2 typeid_hash_extended(typeid, bigint); +/* */ +