Re: Why no CONSTANT for row variables in plpgsql?

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why no CONSTANT for row variables in plpgsql?
Date: 2015-10-19 22:16:22
Message-ID: 56256BB6.6010902@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/18/15 10:16 PM, Tom Lane wrote:
> Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> writes:
>> Is there a particular reason why row and record variables can't be
>> CONSTANT in plpgsql?
>
> Well, you can't usefully do anything with such a variable unless
> it can be initialized, which isn't currently supported either:
>
> regression=# do $$ declare x int8_tbl := row(1,2); begin end $$;
> ERROR: default value for row or record variable is not supported
> LINE 1: do $$ declare x int8_tbl := row(1,2); begin end $$;

Yeah, I assumed the two were related. We also don't allow NOT NULL. This
is all checked in the production in pl_gram.y, but there's nothing
indicating why this is the case. :/

> I have a vague recollection of having looked at this a few years
> ago and realizing it wasn't quite as trivial as one could wish.
> Don't remember why, though. In any case, I'm sure it's fixable
> if someone wants to put in enough effort.

Yeah, was hoping someone knew offhand why this was a problem. Guess I'll
rip the checks out and see what explodes. :)
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lukas Fittl 2015-10-19 22:18:24 Re: SuperUser check in pg_stat_statements
Previous Message Jim Nasby 2015-10-19 22:12:08 Re: SuperUser check in pg_stat_statements