[GENERAL] Immutable functions and cache invalidation.

2017-08-26 Thread Tim Uckun
Say I have a function like this. CREATE OR REPLACE FUNCTION some_constant( ) RETURNS text LANGUAGE 'plpgsql' COST 100 IMMUTABLE ROWS 0 AS $BODY$ begin return 'some_string'; end; $BODY$; Then I have another function that calls it but is also immutable CREATE OR REPLACE FUNCTIO

Re: [GENERAL] Immutable functions, Exceptions and the Query Optimizer

2013-02-18 Thread Albe Laurenz
Cochise Ruhulessin wrote: > Regarding your question about what the CHECK constraint should achieve, I had > abstracted by use case > into Books/Book Types, which may have caused some vagueness. The actual use > case are the following > tables. [...] > CREATE TABLE persons( > person_id int8

Re: [GENERAL] Immutable functions, Exceptions and the Query Optimizer

2013-02-15 Thread Albe Laurenz
Cochise Ruhulessin wrote: > If an immutable function raises an exception, is that exception cached by the > query optimizer? Or does > it only cache in the case that a function actually returns a value? If an error occurs, query processing is terminated, so nothing needs to be cached. PostgreSQL

[GENERAL] Immutable functions, Exceptions and the Query Optimizer

2013-02-14 Thread Cochise Ruhulessin
Hello all, If an immutable function raises an exception, is that exception cached by the query optimizer? Or does it only cache in the case that a function actually returns a value? The use case is a table books(book_id NOT NULL PRIMARY KEY, type_id) wherein type_id is considered immutable (enfor

Re: [GENERAL] immutable functions

2011-11-29 Thread Tom Lane
Andy Chambers writes: > The documentation has this to say about immutable functions... >> or otherwise use information not directly present in its argument list > If the arguments are "row variables", does this allow access to the > data in the row? Sure. regards, tom la

[GENERAL] immutable functions

2011-11-29 Thread Andy Chambers
The documentation has this to say about immutable functions... > or otherwise use information not directly present in its argument list If the arguments are "row variables", does this allow access to the data in the row? For example, is it safe to make the following function definition immutable

Re: [GENERAL] immutable functions and enumerate type casts in indexes

2008-09-03 Thread Edoardo Panfili
Tom Lane ha scritto: Edoardo Panfili <[EMAIL PROTECTED]> writes: labelDatum = DirectFunctionCall1(enum_out,datumIbrido); label = (char *) DatumGetPointer(labelDatum); Just FYI, preferred style for the second line would be label = DatumGetCString(labelDatum); Nearly al

Re: [GENERAL] immutable functions and enumerate type casts in indexes

2008-09-03 Thread Tom Lane
Edoardo Panfili <[EMAIL PROTECTED]> writes: > labelDatum = DirectFunctionCall1(enum_out,datumIbrido); > label = (char *) DatumGetPointer(labelDatum); Just FYI, preferred style for the second line would be label = DatumGetCString(labelDatum); Nearly all standard data types hav

Re: [GENERAL] immutable functions and enumerate type casts in indexes

2008-09-03 Thread Edoardo Panfili
Martijn van Oosterhout ha scritto: On Tue, Sep 02, 2008 at 10:53:03AM +0200, Edoardo Panfili wrote: But i have a little question about parameters of enum_out. Datum enum_out(PG_FUNCTION_ARGS); this is a part of my function --- Datum esterna

Re: [GENERAL] immutable functions and enumerate type casts in indexes

2008-09-02 Thread Martijn van Oosterhout
On Tue, Sep 02, 2008 at 10:53:03AM +0200, Edoardo Panfili wrote: > But i have a little question about parameters of enum_out. > Datum enum_out(PG_FUNCTION_ARGS); > this is a part of my function > --- > Datum esterna_nome2(PG_FUNCTION_ARGS){ >

Re: [GENERAL] immutable functions and enumerate type casts in indexes

2008-09-02 Thread Edoardo Panfili
Tom Lane ha scritto: Edoardo Panfili <[EMAIL PROTECTED]> writes: my enumerated type is (this is a subset) CREATE TYPE hibridation AS ENUM('none','genus','specie'); function declaration CREATE FUNCTION ename(text,boolean,text,text RETURNS text AS 'funzioniGDB.so' LANGUAGE C IMMUTABLE; inde

Re: [GENERAL] immutable functions and enumerate type casts in indexes

2008-09-01 Thread Tom Lane
Edoardo Panfili <[EMAIL PROTECTED]> writes: > my enumerated type is (this is a subset) > CREATE TYPE hibridation AS ENUM('none','genus','specie'); > function declaration > CREATE FUNCTION ename(text,boolean,text,text RETURNS text AS > 'funzioniGDB.so' LANGUAGE C IMMUTABLE; > index creation (the

[GENERAL] immutable functions and enumerate type casts in indexes

2008-09-01 Thread Edoardo Panfili
Hello, I have a problem with enumerated types in functions parameters. my enumerated type is (this is a subset) CREATE TYPE hibridation AS ENUM('none','genus','specie'); function declaration CREATE FUNCTION ename(text,boolean,text,text RETURNS text AS 'funzioniGDB.so' LANGUAGE C IMMUTABLE; i