Skip to content

hstore_pllua

Hstore transform for Lua

pllua · Hstore transform for Lua

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3021hstore_plluapllua1.0LANGMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
PL/Lua pkg 2.0.12; SQL 1.0; no fixed schema.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.019 18 17 16 15plluahstore, pllua
RPMPIGSTY2.0.1219 18 17 16 15pllua_$v-
DEBPGDG2.0.1219 18 17 16 15postgresql-$v-pllua-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
el8.aarch64N/APIGSTY 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
el9.x86_64MISSPIGSTY 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
el9.aarch64MISSPIGSTY 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
el10.x86_64MISSPIGSTY 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
el10.aarch64MISSPIGSTY 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d12.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d12.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d13.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d13.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u22.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u22.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u24.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u24.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u26.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u26.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12

Source

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pllua;		# install by package name
pig install hstore_pllua;		# install by extension name

pig install hstore_pllua -v 19;   # install for PG 19
pig install hstore_pllua -v 18;   # install for PG 18
pig install hstore_pllua -v 17;   # install for PG 17
pig install hstore_pllua -v 16;   # install for PG 16
pig install hstore_pllua -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION hstore_pllua CASCADE; -- requires hstore, pllua

Usage

hstore_pllua: hstore transform for PL/Lua

The hstore_pllua extension provides a transform that allows hstore values to be passed directly to and from PL/Lua functions as native Lua tables, instead of opaque datum objects.

CREATE EXTENSION hstore;
CREATE EXTENSION pllua;
CREATE EXTENSION hstore_pllua;

Using hstore in PL/Lua

With the transform installed, hstore arguments are automatically converted to Lua tables, and Lua tables can be returned as hstore values:

CREATE FUNCTION process_hstore(h hstore) RETURNS hstore LANGUAGE pllua AS $$
  -- h is a Lua table with string keys and string values
  h["new_key"] = "new_value"
  h["modified"] = "true"
  return h
$$;

SELECT process_hstore('name => "Alice", age => "30"'::hstore);

Iterate Over hstore Keys

CREATE FUNCTION hstore_keys(h hstore) RETURNS SETOF text LANGUAGE pllua AS $$
  for k, v in pairs(h) do
    coroutine.yield(k)
  end
$$;

Without this transform, hstore values would need to be manually converted using the hstore type functions.

Table reader