PL/pgSQL

1 program Added 2025-11-05T11:25:01Z Model: google/gemini-2.5-proTemp: 0.4 Evidence Report issue View issues
Aliases: PL/pgsql
Provenance: commit 4c5eafb981 · authored 2025-11-05T12:25:01+01:00 · model google/gemini-2.5-pro

Sources mentioning this language

8 sources · pl_id: pl/plpgsql
LLM (this repo) · 1PldbLinguistPygmentsWikipediaHyperpolyglotRosettacodeWikidata · Q2044345

Wikipedia infobox

Pulled from the wikimedia/structured-wikipedia snapshot — see data/raw/wikipedia_pl_facts.*.jsonl and pl_fact.csv for the long-table provenance.

Designed byPostgreSQL Global Development Group · Jan Wieck
First appeared1998
Influenced byPL/SQL · Ada
Homepagehttps://www.postgresql.org/docs/current/static/plpgsql.html

Extensions claimed by this language

2 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.pgsqllinguistprimary1.4M files
.sqllinguistsecondary31.4M files

Related languages

PL/SQL (0.47)PL/P (0.25)PL/Tcl (0.25)Plexil (0.25)PL/M (0.21)

LLM-contributed programs

PL/pgSQL implementation of an instr() string function

Provenance: commit 4c5eafb981 · authored 2025-11-05T12:25:01+01:00 · model google/gemini-2.5-pro · Temp 0.4
code.sql · license: PostgreSQL License · added: 2025-11-05T11:25:01Z
CREATE FUNCTION instr(text, text) RETURNS integer AS $$
DECLARE
    haystack ALIAS FOR $1;
    needle ALIAS FOR $2;
    pos integer;
    h_len integer;
    n_len integer;
    i integer;
BEGIN
    pos := 0;
    h_len := length(haystack);
    n_len := length(needle);

    IF h_len < n_len OR n_len = 0 THEN
        RETURN 0;
    END IF;

    i := 1;
    WHILE i <= (h_len - n_len + 1) LOOP
        IF substr(haystack, i, n_len) = needle THEN
            pos := i;
            EXIT;
        END IF;
        i := i + 1;
    END LOOP;

    RETURN pos;
END;
$$ LANGUAGE plpgsql;

Real programs from Software Heritage

1 sample mined from derived_datasets/<date>/contents/*.parquet, byte-verified against the SWH archive. Citation-grade qualified SWHIDs preserved.
get_stat_activity.sql · 779 B · ext .sql · seen 2136× in SWH
via heuristicrule h/linguist/.sql/0
swh:1:cnt:b9668f1083290e2af716061aca470fcc93e3d310;origin=https://github.com/PNNL-Comp-Mass-Spec/DBSchema_PgSQL_DMS;anchor=swh:1:rev:ba3195740b6407e08d3a6c8dfe0e2d7454c740c5;path=/dms/get_stat_activity.sql
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
--
-- Name: get_stat_activity(); Type: FUNCTION; Schema: public; Owner: d3l243
--

CREATE OR REPLACE FUNCTION public.get_stat_activity() RETURNS SETOF pg_stat_activity
    LANGUAGE sql SECURITY DEFINER
    AS $$
  select * from pg_stat_activity where datname = current_database() and pid != pg_backend_pid()
$$;


ALTER FUNCTION public.get_stat_activity() OWNER TO d3l243;

--
-- Name: FUNCTION get_stat_activity(); Type: COMMENT; Schema: public; Owner: d3l243
--

COMMENT ON FUNCTION public.get_stat_activity() IS 'created for pgwatch2';

--
-- Name: FUNCTION get_stat_activity(); Type: ACL; Schema: public; Owner: d3l243
--

REVOKE ALL ON FUNCTION public.get_stat_activity() FROM PUBLIC;
GRANT ALL ON FUNCTION public.get_stat_activity() TO pgwatch2;

Disambiguation rules

Linguist heuristic rules that predict this language when one of its claimed extensions is shared with another.
RuleExtKindPredicates (truncated)
h/linguist/.sql/0.sqlpredicates[{"kind": "any", "regexes": ["(?i:^\\\\i\\b|AS\\s+\\$\\$|LANGUAGE\\s+'?plpgsql'?|BEGIN(\\s+WORK)?\\s*;)"]}]

Contribute — propose a file extension

Tell us where to find evidence about PL/pgSQL (mapped to pl/plpgsql). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/PL/pgSQL/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← PL/Perl PL/S →