Re: domains code query

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: domains code query
Date: 2006-08-14 23:39:25
Message-ID: 44E109AD.1020505@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

*
domains.c contains the followng snippet in domain_in():

else* *if* (my_extra->domain_type != domainType)
domain_state_setup(my_extra, domainType, false,
fcinfo->flinfo->fn_mcxt);

We were just looking at this code (in the context of implementing enums) and wondered when this case might arise.
Would it be when more than one domain is used in a table row? Or are we smarter than that?

Putting it another way, how often are fcinfo/flinfo created and reused?

TIA

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: domains code query
Date: 2006-08-14 23:50:04
Message-ID: 26517.1155599404@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> domains.c contains the followng snippet in domain_in():

> else* *if* (my_extra->domain_type != domainType)
> domain_state_setup(my_extra, domainType, false,
> fcinfo->flinfo->fn_mcxt);

> We were just looking at this code (in the context of implementing enums) and wondered when this case might arise.
> Would it be when more than one domain is used in a table row? Or are we smarter than that?

I think it's just defensive programming. The logic was copied from
array_in which does something similar, but AFAIR there's not really
any code path which would feed differing input types to the same
function call within a single query execution. Still, since it takes
only an extra comparison or so to handle the scenario, why not?

regards, tom lane


From: andrew(at)dunslane(dot)net
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: domains code query
Date: 2006-08-15 00:14:24
Message-ID: 3902.24.211.165.134.1155600864.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> domains.c contains the followng snippet in domain_in():
>
>> else* if (my_extra->domain_type != domainType)
>> domain_state_setup(my_extra, domainType, false,
>> fcinfo->flinfo->fn_mcxt);
>
>> We were just looking at this code (in the context of implementing enums)
>> and wondered when this case might arise.
>> Would it be when more than one domain is used in a table row? Or are we
>> smarter than that?
>
> I think it's just defensive programming. The logic was copied from
> array_in which does something similar, but AFAIR there's not really
> any code path which would feed differing input types to the same
> function call within a single query execution. Still, since it takes
> only an extra comparison or so to handle the scenario, why not?
>

Sure. We were hoping it was something like that.

cheers

andrew