Re: A minor patch to mark xml/xslt functions immutable - Mailing list pgsql-patches

From Neil Conway
Subject Re: A minor patch to mark xml/xslt functions immutable
Date
Msg-id 42D610B3.60106@samurai.com
Whole thread Raw
In response to A minor patch to mark xml/xslt functions immutable  ("Ilia Kantor" <ilia@obnovlenie.ru>)
List pgsql-patches
Ilia Kantor wrote:
> Immutability is obvious, because xml procession result depends on the
> document and request solely.

Thanks, applied with some tweaks. I've attached the patch I applied.

-Neil
Index: contrib/xml2/pgxml.sql.in
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql/contrib/xml2/pgxml.sql.in,v
retrieving revision 1.3
diff -c -r1.3 pgxml.sql.in
*** contrib/xml2/pgxml.sql.in    2 Dec 2004 22:21:12 -0000    1.3
--- contrib/xml2/pgxml.sql.in    14 Jul 2005 06:34:02 -0000
***************
*** 1,32 ****
  --SQL for XML parser

  CREATE OR REPLACE FUNCTION xml_valid(text) RETURNS bool
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  CREATE OR REPLACE FUNCTION xml_encode_special_chars(text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  CREATE OR REPLACE FUNCTION xpath_string(text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  CREATE OR REPLACE FUNCTION xpath_nodeset(text,text,text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  CREATE OR REPLACE FUNCTION xpath_number(text,text) RETURNS float4
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  CREATE OR REPLACE FUNCTION xpath_bool(text,text) RETURNS boolean
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  -- List function

  CREATE OR REPLACE FUNCTION xpath_list(text,text,text) RETURNS text
      AS 'MODULE_PATHNAME'
!     LANGUAGE 'c' WITH (isStrict);


  CREATE OR REPLACE FUNCTION xpath_list(text,text) RETURNS text
! AS 'SELECT xpath_list($1,$2,'','')' language 'SQL' WITH (isStrict);



--- 1,32 ----
  --SQL for XML parser

  CREATE OR REPLACE FUNCTION xml_valid(text) RETURNS bool
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  CREATE OR REPLACE FUNCTION xml_encode_special_chars(text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  CREATE OR REPLACE FUNCTION xpath_string(text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  CREATE OR REPLACE FUNCTION xpath_nodeset(text,text,text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  CREATE OR REPLACE FUNCTION xpath_number(text,text) RETURNS float4
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  CREATE OR REPLACE FUNCTION xpath_bool(text,text) RETURNS boolean
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  -- List function

  CREATE OR REPLACE FUNCTION xpath_list(text,text,text) RETURNS text
      AS 'MODULE_PATHNAME'
!     LANGUAGE 'c' STRICT IMMUTABLE;


  CREATE OR REPLACE FUNCTION xpath_list(text,text) RETURNS text
! AS 'SELECT xpath_list($1,$2,'','')' language 'SQL' STRICT IMMUTABLE;



***************
*** 34,50 ****


  CREATE OR REPLACE FUNCTION xpath_nodeset(text,text) RETURNS text AS
! 'SELECT xpath_nodeset($1,$2,'''','''')' language 'SQL' WITH (isStrict);


  CREATE OR REPLACE FUNCTION xpath_nodeset(text,text,text) RETURNS text AS
! 'SELECT xpath_nodeset($1,$2,'''',$3)' language 'SQL' WITH (isStrict);

  -- Table function

  CREATE OR REPLACE FUNCTION xpath_table(text,text,text,text,text) RETURNS setof record
      AS 'MODULE_PATHNAME'
!     LANGUAGE 'c' WITH (isStrict);

  -- XSLT functions
  -- Delete from here to the end of the file if you are not compiling with
--- 34,50 ----


  CREATE OR REPLACE FUNCTION xpath_nodeset(text,text) RETURNS text AS
! 'SELECT xpath_nodeset($1,$2,'''','''')' language 'SQL' STRICT IMMUTABLE;


  CREATE OR REPLACE FUNCTION xpath_nodeset(text,text,text) RETURNS text AS
! 'SELECT xpath_nodeset($1,$2,'''',$3)' language 'SQL' STRICT IMMUTABLE;

  -- Table function

  CREATE OR REPLACE FUNCTION xpath_table(text,text,text,text,text) RETURNS setof record
      AS 'MODULE_PATHNAME'
!     LANGUAGE 'c' STRICT IMMUTABLE;

  -- XSLT functions
  -- Delete from here to the end of the file if you are not compiling with
***************
*** 52,60 ****


  CREATE OR REPLACE FUNCTION xslt_process(text,text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);

  -- the function checks for the correct argument count

  CREATE OR REPLACE FUNCTION xslt_process(text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict);
--- 52,60 ----


  CREATE OR REPLACE FUNCTION xslt_process(text,text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

  -- the function checks for the correct argument count

  CREATE OR REPLACE FUNCTION xslt_process(text,text) RETURNS text
!     AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT IMMUTABLE;

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: thousands comma numeric formatting in psql
Next
From: Peter Eisentraut
Date:
Subject: Re: Final cleanup of SQL:1999 references