@@ -5683,6 +5683,46 @@ impl fmt::Display for FunctionBehavior {
56835683 }
56845684}
56855685
5686+ /// These attributes describe the behavior of the function when called with a null argument.
5687+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
5688+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5689+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
5690+ pub enum FunctionCalledOnNull {
5691+ CalledOnNullInput ,
5692+ ReturnsNullOnNullInput ,
5693+ Strict ,
5694+ }
5695+
5696+ impl fmt:: Display for FunctionCalledOnNull {
5697+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
5698+ match self {
5699+ FunctionCalledOnNull :: CalledOnNullInput => write ! ( f, "CALLED ON NULL INPUT" ) ,
5700+ FunctionCalledOnNull :: ReturnsNullOnNullInput => write ! ( f, "RETURNS NULL ON NULL INPUT" ) ,
5701+ FunctionCalledOnNull :: Strict => write ! ( f, "STRICT" ) ,
5702+ }
5703+ }
5704+ }
5705+
5706+ /// If it is safe for PostgreSQL to call the function from multiple threads at once
5707+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
5708+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5709+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
5710+ pub enum FunctionParallel {
5711+ Unsafe ,
5712+ Restricted ,
5713+ Safe ,
5714+ }
5715+
5716+ impl fmt:: Display for FunctionParallel {
5717+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
5718+ match self {
5719+ FunctionParallel :: Unsafe => write ! ( f, "PARALLEL UNSAFE" ) ,
5720+ FunctionParallel :: Restricted => write ! ( f, "PARALLEL RESTRICTED" ) ,
5721+ FunctionParallel :: Safe => write ! ( f, "PARALLEL SAFE" ) ,
5722+ }
5723+ }
5724+ }
5725+
56865726#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
56875727#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
56885728#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -5703,7 +5743,7 @@ impl fmt::Display for FunctionDefinition {
57035743
57045744/// Postgres specific feature.
57055745///
5706- /// See [Postgresdocs ](https://www.postgresql.org/docs/15/sql-createfunction.html)
5746+ /// See [Postgres docs ](https://www.postgresql.org/docs/15/sql-createfunction.html)
57075747/// for more details
57085748#[ derive( Debug , Default , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
57095749#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
@@ -5713,6 +5753,10 @@ pub struct CreateFunctionBody {
57135753 pub language : Option < Ident > ,
57145754 /// IMMUTABLE | STABLE | VOLATILE
57155755 pub behavior : Option < FunctionBehavior > ,
5756+ /// CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
5757+ pub called_on_null : Option < FunctionCalledOnNull > ,
5758+ /// PARALLEL { UNSAFE | RESTRICTED | SAFE }
5759+ pub parallel : Option < FunctionParallel > ,
57165760 /// AS 'definition'
57175761 ///
57185762 /// Note that Hive's `AS class_name` is also parsed here.
@@ -5731,6 +5775,12 @@ impl fmt::Display for CreateFunctionBody {
57315775 if let Some ( behavior) = & self . behavior {
57325776 write ! ( f, " {behavior}" ) ?;
57335777 }
5778+ if let Some ( called_on_null) = & self . called_on_null {
5779+ write ! ( f, " {called_on_null}" ) ?;
5780+ }
5781+ if let Some ( parallel) = & self . parallel {
5782+ write ! ( f, " {parallel}" ) ?;
5783+ }
57345784 if let Some ( definition) = & self . as_ {
57355785 write ! ( f, " AS {definition}" ) ?;
57365786 }
0 commit comments