Proposal: associative arrays for plpgsql (concept)

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Proposal: associative arrays for plpgsql (concept)
Date: 2005-06-29 15:59:26
Message-ID: Pine.LNX.4.44.0506291737460.18770-100000@kix.fsv.cvut.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

The concept is from Oracle 9i, but with some changes.

http://www.oracle-10g.de/oracle_10g_documentation/appdev.101/b10807/05_colls.htm#i35672

Associative arrays are any arrays with index. Will be created

DECLARE
x varchar[] INDEX BY VARCHAR = '{}'; -- some format, haven't idea

then I can use anywhere x[key];

two enhancing FOR cycle:

-- iteration over all values
FOR i IN VALUES OF x LOOP -- x array or associative array
END LOOP;

-- iteration over all keys
FOR i IN INDICIES OF x LOOP -- x associatice array
x[i]
END LOOP;

new functions:

exists(x, key);
delete(x, key);

index is accessable only from PL/pgSQL. Associative arrays can be spec
PostgreSQL type or clasic arrays with hash index.

Comments, notes?

Regards
Pavel Stehule

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Affan Bin Salman 2005-06-29 16:21:20 Re: Implementing SQL/PSM for PG 8.2
Previous Message Tom Lane 2005-06-29 14:34:56 Re: Startup successful message, even on failure