r/PostgreSQL • u/linuxhiker • 16h ago
Projects plx: The Excellent Transpiler 3.1.0 releasd
plx is a PostgreSQL extension. When you run CREATE FUNCTION ... LANGUAGE plx*, plx transpiles the body to plpgsql and stores that plpgsql in pg_proc.prosrc. At run time the function is executed by PostgreSQL's own plpgsql interpreter. There is no separate language runtime loaded into the backend, the generated plpgsql is visible in the catalog, and every plpgsql construct is reachable from every dialect.
[3.1.0] - 2026-11-21
3.1.0 adds two dialects, plxlua and plxcsharp. Nothing that 3.0.0 does changes: functions in the other dialects transpile as before.
Added
- plxlua, a Lua dialect (
LANGUAGE plxlua). Lua's keyword-endblocks,localdeclarations with type inference and--::annotations,<const>,if/elseif,while,repeat ... until, the numericfor(any step) andfor ... in query(...)/ipairs(...), thegoto continueidiom, andreturninto OUT parameters. Errors are raised witherror(...),error{message = ..., sqlstate = ...},assertandprint, and handled withpcall(function() ... end), whoseerrcarrieserr.sqlstateand the other diagnostics fields. In expressions:..,~=,nil,#, table constructors as arrays,//, and thex or d,c and a or bandc and v or didioms, with a subset of thestring,mathandtablelibraries. Locals keep Lua's block scope, ands = s .. euses the string builder. See doc/plxlua.md. - plxcsharp, a C# dialect (
LANGUAGE plxcsharp). Declarations put the type first and C# types map to PostgreSQL types (inttointeger,stringtotext,decimaltonumeric,DateTimetotimestamp,T[]to arrays);vartakes the type of its value. Regular, verbatim (@"..."), raw ("""...""") and interpolated ($"...") strings work, and an interpolated string passed toquery,executeand the other SQL intrinsics is a SQL template whose values are bound.+is string concatenation when an operand is known to be a string. Statements:if,while,do/while,for,foreachover a query, an array or a string,switchand switch expressions,try/catch/finallywith exception classes andwhen (e.SqlState == ...)filters,throw,yield returnfor set-returning functions,Console.WriteLineasRAISE NOTICE, andStringBuilderands += xon the string builder, with a set of mapped .NET members (string,Math,Convert,DateTime,Guid, ...). See doc/plxcsharp.md. make oraclecheckruns plxlua and plxcsharp programs and compares their results with what real Lua and C# print for the same programs.