[REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions

Поиск
Список
Период
Сортировка
Искать

[REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions

От:
Abhijit Menon-Sen <ams@2ndQuadrant.com>
Дата:
(Cc: to pgsql-bugs dropped.)

At 2014-03-17 18:24:55 +1100, kommi.haribabu@gmail.com wrote:
>
> *** a/doc/src/sgml/xfunc.sgml
> --- b/doc/src/sgml/xfunc.sgml
> ***************
> *** 153,159 **** SELECT clean_emp();
> --- 153,186 ----
>       (\</>) (assuming escape string syntax) in the body of
>       the function (see ).
>      
> +    
> +    
> +     Parsing mechanism of a function
>   
> +    
> +     function
> +     parsing mechanism
> +    

I suggest "Catalog changes within functions" instead of the above title.

> +     
> +      The body of an SQL function is parsed as if it were a single - multi-part
> +      statement and thus uses a constant snapshot of the system catalogs for
> +      every sub-statement therein. Commands that alter the catalog will likely not
> +      work as expected.
> +     
> + 
> +       
> +      For example: Issuing "CREATE TEMP TABLE" within an SQL function will add
> +      the table to the catalog but subsequent statements in the same function will
> +      not see those additions and thus the temporary table will be invisible to them.
> +     
> + 
> +       
> +      Thus it is generally advised that PL/pgSQL</> be used, instead of
> +      SQL, when any catalog visibilities are required in the same function.
> +     
> +    

I don't think that much text is warranted. I suggest something like the
following condensed wording:
       The body of an SQL function is parsed as if it were a single    multi-part statement, using a constant snapshot of the system    catalogs. The effect of any commands that alter the catalogs    (e.g. "CREATE TEMP TABLE") will therefore not be visible to    subsequent commands in the function body.   
       The recommended workaround is to use PL/PgSQL</>.   

Does that seem sensible to you?

-- Abhijit


Re: [REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions

От:
Haribabu Kommi <kommi.haribabu@gmail.com>
Дата:
Вложения:
On Tue, Jun 17, 2014 at 12:30 AM, Abhijit Menon-Sen  wrote:
> (Cc: to pgsql-bugs dropped.)
>
> At 2014-03-17 18:24:55 +1100, kommi.haribabu@gmail.com wrote:
>>
>> *** a/doc/src/sgml/xfunc.sgml
>> --- b/doc/src/sgml/xfunc.sgml
>> ***************
>> *** 153,159 **** SELECT clean_emp();
>> --- 153,186 ----
>>       (\</>) (assuming escape string syntax) in the body of
>>       the function (see ).
>>      
>> +
>> +    
>> +     Parsing mechanism of a function
>>
>> +    
>> +     function
>> +     parsing mechanism
>> +    
>
> I suggest "Catalog changes within functions" instead of the above title.
>
>> +     
>> +      The body of an SQL function is parsed as if it were a single - multi-part
>> +      statement and thus uses a constant snapshot of the system catalogs for
>> +      every sub-statement therein. Commands that alter the catalog will likely not
>> +      work as expected.
>> +     
>> +
>> +     
>> +      For example: Issuing "CREATE TEMP TABLE" within an SQL function will add
>> +      the table to the catalog but subsequent statements in the same function will
>> +      not see those additions and thus the temporary table will be invisible to them.
>> +     
>> +
>> +     
>> +      Thus it is generally advised that PL/pgSQL</> be used, instead of
>> +      SQL, when any catalog visibilities are required in the same function.
>> +     
>> +    
>
> I don't think that much text is warranted. I suggest something like the
> following condensed wording:
>
>     
>      The body of an SQL function is parsed as if it were a single
>      multi-part statement, using a constant snapshot of the system
>      catalogs. The effect of any commands that alter the catalogs
>      (e.g. "CREATE TEMP TABLE") will therefore not be visible to
>      subsequent commands in the function body.
>     
>
>     
>      The recommended workaround is to use PL/PgSQL</>.
>     
>
> Does that seem sensible to you?

Looks good, Thanks for the review.
Updated patch attached.

Regards,
Hari Babu
Fujitsu Australia

Re: Re: [REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions

От:
Abhijit Menon-Sen <ams@2ndquadrant.com>
Дата:
Thanks, I've marked this ready for committer.

-- Abhijit


Re: Re: [REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Haribabu Kommi  writes:
> Updated patch attached.

I revised this a bit more and committed it.
		regards, tom lane


FAQ