@@ -39,15 +39,25 @@ use crate::tokenizer::Span;
3939#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4040#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4141pub enum RoleOption {
42+ /// Enable or disable BYPASSRLS.
4243 BypassRLS ( bool ) ,
44+ /// Connection limit expression.
4345 ConnectionLimit ( Expr ) ,
46+ /// CREATEDB flag.
4447 CreateDB ( bool ) ,
48+ /// CREATEROLE flag.
4549 CreateRole ( bool ) ,
50+ /// INHERIT flag.
4651 Inherit ( bool ) ,
52+ /// LOGIN flag.
4753 Login ( bool ) ,
54+ /// Password value or NULL password.
4855 Password ( Password ) ,
56+ /// Replication privilege flag.
4957 Replication ( bool ) ,
58+ /// SUPERUSER flag.
5059 SuperUser ( bool ) ,
60+ /// `VALID UNTIL` expression.
5161 ValidUntil ( Expr ) ,
5262}
5363
@@ -104,8 +114,11 @@ impl fmt::Display for RoleOption {
104114#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
105115#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
106116pub enum SetConfigValue {
117+ /// Use the default value.
107118 Default ,
119+ /// Use the current value (`FROM CURRENT`).
108120 FromCurrent ,
121+ /// Set to the provided expression value.
109122 Value ( Expr ) ,
110123}
111124
@@ -116,7 +129,9 @@ pub enum SetConfigValue {
116129#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
117130#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
118131pub enum ResetConfig {
132+ /// Reset all configuration parameters.
119133 ALL ,
134+ /// Reset the named configuration parameter.
120135 ConfigName ( ObjectName ) ,
121136}
122137
@@ -127,28 +142,48 @@ pub enum ResetConfig {
127142pub enum AlterRoleOperation {
128143 /// Generic
129144 RenameRole {
145+ /// Role name to rename.
130146 role_name : Ident ,
131147 } ,
132148 /// MS SQL Server
133149 /// <https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-role-transact-sql>
134150 AddMember {
151+ /// Member name to add to the role.
135152 member_name : Ident ,
136153 } ,
154+ /// MS SQL Server
155+ ///
156+ /// <https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-role-transact-sql>
137157 DropMember {
158+ /// Member name to remove from the role.
138159 member_name : Ident ,
139160 } ,
140161 /// PostgreSQL
141162 /// <https://www.postgresql.org/docs/current/sql-alterrole.html>
142163 WithOptions {
164+ /// Role options to apply.
143165 options : Vec < RoleOption > ,
144166 } ,
167+ /// PostgreSQL
168+ /// <https://www.postgresql.org/docs/current/sql-alterrole.html>
169+ ///
170+ /// `SET configuration_parameter { TO | = } { value | DEFAULT }`
145171 Set {
172+ /// Configuration name to set.
146173 config_name : ObjectName ,
174+ /// Value to assign to the configuration.
147175 config_value : SetConfigValue ,
176+ /// Optional database scope for the setting.
148177 in_database : Option < ObjectName > ,
149178 } ,
179+ /// PostgreSQL
180+ /// <https://www.postgresql.org/docs/current/sql-alterrole.html>
181+ ///
182+ /// `RESET configuration_parameter` | `RESET ALL`
150183 Reset {
184+ /// Configuration to reset.
151185 config_name : ResetConfig ,
186+ /// Optional database scope for the reset.
152187 in_database : Option < ObjectName > ,
153188 } ,
154189}
@@ -205,14 +240,22 @@ impl fmt::Display for AlterRoleOperation {
205240#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
206241#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
207242pub enum Use {
208- Catalog ( ObjectName ) , // e.g. `USE CATALOG foo.bar`
209- Schema ( ObjectName ) , // e.g. `USE SCHEMA foo.bar`
210- Database ( ObjectName ) , // e.g. `USE DATABASE foo.bar`
211- Warehouse ( ObjectName ) , // e.g. `USE WAREHOUSE foo.bar`
212- Role ( ObjectName ) , // e.g. `USE ROLE PUBLIC`
213- SecondaryRoles ( SecondaryRoles ) , // e.g. `USE SECONDARY ROLES ALL`
214- Object ( ObjectName ) , // e.g. `USE foo.bar`
215- Default , // e.g. `USE DEFAULT`
243+ /// Switch to the given catalog (e.g. `USE CATALOG ...`).
244+ Catalog ( ObjectName ) ,
245+ /// Switch to the given schema (e.g. `USE SCHEMA ...`).
246+ Schema ( ObjectName ) ,
247+ /// Switch to the given database (e.g. `USE DATABASE ...`).
248+ Database ( ObjectName ) ,
249+ /// Switch to the given warehouse (e.g. `USE WAREHOUSE ...`).
250+ Warehouse ( ObjectName ) ,
251+ /// Switch to the given role (e.g. `USE ROLE ...`).
252+ Role ( ObjectName ) ,
253+ /// Use secondary roles specification (e.g. `USE SECONDARY ROLES ...`).
254+ SecondaryRoles ( SecondaryRoles ) ,
255+ /// Use the specified object (e.g. `USE foo.bar`).
256+ Object ( ObjectName ) ,
257+ /// Reset to default (e.g. `USE DEFAULT`).
258+ Default ,
216259}
217260
218261impl fmt:: Display for Use {
@@ -239,8 +282,11 @@ impl fmt::Display for Use {
239282#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
240283#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
241284pub enum SecondaryRoles {
285+ /// Use all secondary roles.
242286 All ,
287+ /// Use no secondary roles.
243288 None ,
289+ /// Explicit list of secondary roles.
244290 List ( Vec < Ident > ) ,
245291}
246292
@@ -260,25 +306,43 @@ impl fmt::Display for SecondaryRoles {
260306#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
261307#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
262308pub struct CreateRole {
309+ /// Role names to create.
263310 pub names : Vec < ObjectName > ,
311+ /// Whether `IF NOT EXISTS` was specified.
264312 pub if_not_exists : bool ,
265313 // Postgres
314+ /// Whether `LOGIN` was specified.
266315 pub login : Option < bool > ,
316+ /// Whether `INHERIT` was specified.
267317 pub inherit : Option < bool > ,
318+ /// Whether `BYPASSRLS` was specified.
268319 pub bypassrls : Option < bool > ,
320+ /// Optional password for the role.
269321 pub password : Option < Password > ,
322+ /// Whether `SUPERUSER` was specified.
270323 pub superuser : Option < bool > ,
324+ /// Whether `CREATEDB` was specified.
271325 pub create_db : Option < bool > ,
326+ /// Whether `CREATEROLE` was specified.
272327 pub create_role : Option < bool > ,
328+ /// Whether `REPLICATION` privilege was specified.
273329 pub replication : Option < bool > ,
330+ /// Optional connection limit expression.
274331 pub connection_limit : Option < Expr > ,
332+ /// Optional account validity expression.
275333 pub valid_until : Option < Expr > ,
334+ /// Members of `IN ROLE` clause.
276335 pub in_role : Vec < Ident > ,
336+ /// Members of `IN GROUP` clause.
277337 pub in_group : Vec < Ident > ,
338+ /// Roles listed in `ROLE` clause.
278339 pub role : Vec < Ident > ,
340+ /// Users listed in `USER` clause.
279341 pub user : Vec < Ident > ,
342+ /// Admin users listed in `ADMIN` clause.
280343 pub admin : Vec < Ident > ,
281344 // MSSQL
345+ /// Optional authorization owner.
282346 pub authorization_owner : Option < ObjectName > ,
283347}
284348
0 commit comments