Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
PostgreSQL
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Procedural languages === Procedural languages allow developers to extend the database with custom [[subroutine]]s (functions), often called ''[[stored procedure]]s''. These functions can be used to build [[database trigger]]s (functions invoked on modification of certain data) and custom data types and [[aggregate function]]s.<ref>{{cite web|url=https://www.postgresql.org/docs/current/server-programming.html|title=Server Programming|access-date=19 May 2019|website=PostgreSQL documentation}}</ref> Procedural languages can also be invoked without defining a function, using a DO command at SQL level.<ref>{{cite web|url=https://www.postgresql.org/docs/current/sql-do.html|title=DO|access-date=19 May 2019|website=PostgreSQL documentation}}</ref> Languages are divided into two groups: Procedures written in ''safe'' languages are [[Sandbox (computer security)|sandboxed]] and can be safely created and used by any user. Procedures written in ''unsafe'' languages can only be created by [[superuser]]s, because they allow bypassing a database's security restrictions, but can also access sources external to the database. Some languages like Perl provide both safe and unsafe versions. PostgreSQL has built-in support for three procedural languages: * Plain SQL (safe). Simpler SQL functions can get [[inline expansion|expanded inline]] into the calling (SQL) query, which saves function call overhead and allows the query optimizer to "see inside" the function. * Procedural Language/PostgreSQL ([[PL/pgSQL]]) (safe), which resembles Oracle's Procedural Language for SQL ([[PL/SQL]]) procedural language and SQL/Persistent Stored Modules ([[SQL/PSM]]). * [[C (programming language)|C]] (unsafe), which allows loading one or more custom [[shared library]] into the database. Functions written in C offer the best performance, but bugs in code can crash and potentially corrupt the database. Most built-in functions are written in C. In addition, PostgreSQL allows procedural languages to be loaded into the database through extensions. Three language extensions are included with PostgreSQL to support [[Perl]], [[Tcl]], and [[Python (programming language)|Python]]. For Python, the current {{nowrap|Python 3}} is used, and the discontinued {{nowrap|Python 2}} is no longer supported as of PostgreSQL 15. Both were supported previously, defaulting to {{nowrap|Python 2}}, while old and new versions couldn't be used in the same session.<ref>{{cite web|url=https://www.postgresql.org/docs/current/plpython.html|title=PL/Python - Python Procedural Language|access-date=October 23, 2022|website=PostgreSQL documentation}}</ref> External projects provide support for many other languages,<ref>{{cite web |date=March 31, 2016 |title=Procedural Languages |publisher=postgresql.org |url=https://www.postgresql.org/docs/current/static/external-pl.html |access-date=April 7, 2016}}</ref> including PL/[[Java (programming language)|Java]], [[JavaScript]] (PL/V8), PL/[[Julia (programming language)|Julia]],<ref name="PL/Julia">{{Cite web|date=2020-03-08|title=PL/Julia extension ( minimal )|url=https://discourse.julialang.org/t/pl-julia-extension-minimal/34232/2|access-date=2021-08-26|website=JuliaLang|language=en}}</ref> PL/[[R (programming language)|R]],<ref>{{Cite web|url=https://github.com/postgres-plr/plr|title=postgres-plr/plr|date=June 17, 2021|via=GitHub}}</ref> PL/[[Ruby (programming language)|Ruby]], and others.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
PostgreSQL
(section)
Add topic