Skip to main content

Module plpgsql_locals

Module plpgsql_locals 

Source
Expand description

Extract PL/pgSQL function parameters and DECLARE’d locals from the buffer text so completion can surface them inside a function body.

Approach: walk backwards from offset to the most recent CREATE [OR REPLACE] FUNCTION|PROCEDURE <name> (...) header. Parse its parameter list, then continue forward to find any DECLARE ... BEGIN blocks before the cursor. Both contribute completion items.

Structs§

Locals

Functions§

extract
Scan the buffer for the function header that encloses offset. When the cursor sits outside any function the returned struct is empty.
push_items
Push Locals as completion items.
type_of
Look up the declared type of a PL/pgSQL local by name. Searches parameters first, then DECLARE’d locals. Case-insensitive match. Returns the raw type string (users, INT, promo_codes%ROWTYPE, etc.) so callers can decide what to do with it.