Sign inSign up

sibedge/postgres-plv8-bigint

By sibedge

•Updated about 1 year ago

Docker image with installed PLV8 extension and BigInt numbers support on PostgreSQL 17 and 16

Image
1

10K+

sibedge/postgres-plv8-bigint repository overview

⁠Postgres | PLV8 (BigInt serialization support mod)

Compact Debian/Alpine based docker image for PLV8 on Postgres incl. latest 17.5 and 16.10. Runs on Windows, Linux and Mac (with Apple silicon M1/M2/M3 support). Alpine-based images are enhanced adaptations of the official Postgres image⁠, while Debian-based images are expanded versions of the Bitnami PostgreSQL package⁠. Unlike default PLV8 build⁠ this modification supports BigInt numbers.

Support and periodic update releases for all versions PostgreSQL 17 and PostgreSQL 16.

This repository is free to use.

⁠amd64, arm64 architectures support:
⁠Only amd64 architecture support:

⁠How to use

This image is installed like the standard Postgres image. The only discrepancy is the complement PLV8 extension.

Create extension script should be executed first:

CREATE EXTENSION plv8;

Then you can perform SQL query:

DO $$
  plv8.elog(NOTICE, plv8.version);
$$ LANGUAGE plv8;

You should see the version of the PLV8 extension installed.

⁠Image mods

Because of BigInt serialization issue this image comes in two variants:

⁠Test the differences in work:
DO $$
  const sql = "SELECT COUNT(*) FROM generate_series(1, 100);";
  const data = plv8.execute(sql);
  plv8.elog(NOTICE, JSON.stringify(data[0]));
$$ LANGUAGE plv8;
  • sibedge/postgres-plv8 result: ERROR: TypeError: Do not know how to serialize a BigInt
  • sibedge/postgres-plv8-bigint result: NOTICE: {"count":100}

Conversion to JSONB test:

CREATE TABLE test
(
  id SERIAL PRIMARY KEY NOT NULL,
  comment text
);

INSERT INTO test(comment)
    VALUES ('abc'), ('def');

CREATE OR REPLACE FUNCTION get_count(table_name text)
  RETURNS jsonb
  LANGUAGE plv8 IMMUTABLE AS
$$
    const sql = `SELECT COUNT(*) AS cnt FROM "${table_name}"`;
    const data = plv8.execute(sql);
    return data[0];
$$;

SELECT * FROM get_count('test');
  • sibedge/postgres-plv8 result: {"cnt": "2"}
  • sibedge/postgres-plv8-bigint result: {"cnt": 2}

⁠Contact us

Ask your questions via email: [email protected]⁠

Tag summary

Content type

Image

Digest

sha256:818b25412…

Size

111.7 MB

Last updated

about 1 year ago

docker pull sibedge/postgres-plv8-bigint