1#[cfg(not(feature = "std"))]
22use alloc::vec::Vec;
23use core::fmt;
24
25#[cfg(feature = "serde")]
26use serde::{Deserialize, Serialize};
27
28#[cfg(feature = "visitor")]
29use sqlparser_derive::{Visit, VisitMut};
30
31use super::{display_comma_separated, Expr, Ident, Password, Spanned};
32use crate::ast::{
33 display_separated, CascadeOption, CurrentGrantsKind, GrantObjects, Grantee, GranteeName,
34 ObjectName, Privileges,
35};
36use crate::tokenizer::Span;
37
38#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
40#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
41#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
42pub enum RoleKeyword {
43 Role,
45 Group,
48}
49
50impl fmt::Display for RoleKeyword {
51 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52 f.write_str(match self {
53 RoleKeyword::Role => "ROLE",
54 RoleKeyword::Group => "GROUP",
55 })
56 }
57}
58
59#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
63#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
64#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
65pub enum RoleOption {
66 BypassRLS(bool),
68 ConnectionLimit(Expr),
70 CreateDB(bool),
72 CreateRole(bool),
74 Inherit(bool),
76 Login(bool),
78 Password(Password),
80 Replication(bool),
82 SuperUser(bool),
84 ValidUntil(Expr),
86}
87
88impl fmt::Display for RoleOption {
89 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
90 match self {
91 RoleOption::BypassRLS(value) => {
92 write!(f, "{}", if *value { "BYPASSRLS" } else { "NOBYPASSRLS" })
93 }
94 RoleOption::ConnectionLimit(expr) => {
95 write!(f, "CONNECTION LIMIT {expr}")
96 }
97 RoleOption::CreateDB(value) => {
98 write!(f, "{}", if *value { "CREATEDB" } else { "NOCREATEDB" })
99 }
100 RoleOption::CreateRole(value) => {
101 write!(f, "{}", if *value { "CREATEROLE" } else { "NOCREATEROLE" })
102 }
103 RoleOption::Inherit(value) => {
104 write!(f, "{}", if *value { "INHERIT" } else { "NOINHERIT" })
105 }
106 RoleOption::Login(value) => {
107 write!(f, "{}", if *value { "LOGIN" } else { "NOLOGIN" })
108 }
109 RoleOption::Password(password) => match password {
110 Password::Password(expr) => write!(f, "PASSWORD {expr}"),
111 Password::NullPassword => write!(f, "PASSWORD NULL"),
112 },
113 RoleOption::Replication(value) => {
114 write!(
115 f,
116 "{}",
117 if *value {
118 "REPLICATION"
119 } else {
120 "NOREPLICATION"
121 }
122 )
123 }
124 RoleOption::SuperUser(value) => {
125 write!(f, "{}", if *value { "SUPERUSER" } else { "NOSUPERUSER" })
126 }
127 RoleOption::ValidUntil(expr) => {
128 write!(f, "VALID UNTIL {expr}")
129 }
130 }
131 }
132}
133
134#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
138#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
139#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
140pub enum SetConfigValue {
141 Default,
143 FromCurrent,
145 Value(Expr),
147}
148
149#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
153#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
154#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
155pub enum ResetConfig {
156 ALL,
158 ConfigName(ObjectName),
160}
161
162#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
164#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
165#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
166pub enum AlterRoleOperation {
167 RenameRole {
169 role_name: Ident,
171 },
172 AddMember {
175 member_name: Ident,
177 },
178 DropMember {
182 member_name: Ident,
184 },
185 WithOptions {
188 options: Vec<RoleOption>,
190 },
191 Set {
196 config_name: ObjectName,
198 config_value: SetConfigValue,
200 in_database: Option<ObjectName>,
202 },
203 Reset {
208 config_name: ResetConfig,
210 in_database: Option<ObjectName>,
212 },
213}
214
215impl fmt::Display for AlterRoleOperation {
216 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
217 match self {
218 AlterRoleOperation::RenameRole { role_name } => {
219 write!(f, "RENAME TO {role_name}")
220 }
221 AlterRoleOperation::AddMember { member_name } => {
222 write!(f, "ADD MEMBER {member_name}")
223 }
224 AlterRoleOperation::DropMember { member_name } => {
225 write!(f, "DROP MEMBER {member_name}")
226 }
227 AlterRoleOperation::WithOptions { options } => {
228 write!(f, "WITH {}", display_separated(options, " "))
229 }
230 AlterRoleOperation::Set {
231 config_name,
232 config_value,
233 in_database,
234 } => {
235 if let Some(database_name) = in_database {
236 write!(f, "IN DATABASE {database_name} ")?;
237 }
238
239 match config_value {
240 SetConfigValue::Default => write!(f, "SET {config_name} TO DEFAULT"),
241 SetConfigValue::FromCurrent => write!(f, "SET {config_name} FROM CURRENT"),
242 SetConfigValue::Value(expr) => write!(f, "SET {config_name} TO {expr}"),
243 }
244 }
245 AlterRoleOperation::Reset {
246 config_name,
247 in_database,
248 } => {
249 if let Some(database_name) = in_database {
250 write!(f, "IN DATABASE {database_name} ")?;
251 }
252
253 match config_name {
254 ResetConfig::ALL => write!(f, "RESET ALL"),
255 ResetConfig::ConfigName(name) => write!(f, "RESET {name}"),
256 }
257 }
258 }
259 }
260}
261
262#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
264#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
265#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
266pub enum Use {
267 Catalog(ObjectName),
269 Schema(ObjectName),
271 Database(ObjectName),
273 Warehouse(ObjectName),
275 Role(ObjectName),
277 SecondaryRoles(SecondaryRoles),
279 Object(ObjectName),
281 Default,
283}
284
285impl fmt::Display for Use {
286 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
287 f.write_str("USE ")?;
288 match self {
289 Use::Catalog(name) => write!(f, "CATALOG {name}"),
290 Use::Schema(name) => write!(f, "SCHEMA {name}"),
291 Use::Database(name) => write!(f, "DATABASE {name}"),
292 Use::Warehouse(name) => write!(f, "WAREHOUSE {name}"),
293 Use::Role(name) => write!(f, "ROLE {name}"),
294 Use::SecondaryRoles(secondary_roles) => {
295 write!(f, "SECONDARY ROLES {secondary_roles}")
296 }
297 Use::Object(name) => write!(f, "{name}"),
298 Use::Default => write!(f, "DEFAULT"),
299 }
300 }
301}
302
303#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
306#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
307#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
308pub enum SecondaryRoles {
309 All,
311 None,
313 List(Vec<Ident>),
315}
316
317impl fmt::Display for SecondaryRoles {
318 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
319 match self {
320 SecondaryRoles::All => write!(f, "ALL"),
321 SecondaryRoles::None => write!(f, "NONE"),
322 SecondaryRoles::List(roles) => write!(f, "{}", display_comma_separated(roles)),
323 }
324 }
325}
326
327#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
330#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
331#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
332pub struct CreateRole {
333 pub keyword: RoleKeyword,
335 pub names: Vec<ObjectName>,
337 pub if_not_exists: bool,
339 pub login: Option<bool>,
342 pub inherit: Option<bool>,
344 pub bypassrls: Option<bool>,
346 pub password: Option<Password>,
348 pub superuser: Option<bool>,
350 pub create_db: Option<bool>,
352 pub create_role: Option<bool>,
354 pub replication: Option<bool>,
356 pub connection_limit: Option<Expr>,
358 pub valid_until: Option<Expr>,
360 pub in_role: Vec<Ident>,
362 pub in_group: Vec<Ident>,
364 pub role: Vec<Ident>,
366 pub user: Vec<Ident>,
368 pub admin: Vec<Ident>,
370 pub authorization_owner: Option<ObjectName>,
373}
374
375impl fmt::Display for CreateRole {
376 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
377 write!(
378 f,
379 "CREATE {keyword} {if_not_exists}{names}{superuser}{create_db}{create_role}{inherit}{login}{replication}{bypassrls}",
380 keyword = self.keyword,
381 if_not_exists = if self.if_not_exists { "IF NOT EXISTS " } else { "" },
382 names = display_separated(&self.names, ", "),
383 superuser = match self.superuser {
384 Some(true) => " SUPERUSER",
385 Some(false) => " NOSUPERUSER",
386 None => ""
387 },
388 create_db = match self.create_db {
389 Some(true) => " CREATEDB",
390 Some(false) => " NOCREATEDB",
391 None => ""
392 },
393 create_role = match self.create_role {
394 Some(true) => " CREATEROLE",
395 Some(false) => " NOCREATEROLE",
396 None => ""
397 },
398 inherit = match self.inherit {
399 Some(true) => " INHERIT",
400 Some(false) => " NOINHERIT",
401 None => ""
402 },
403 login = match self.login {
404 Some(true) => " LOGIN",
405 Some(false) => " NOLOGIN",
406 None => ""
407 },
408 replication = match self.replication {
409 Some(true) => " REPLICATION",
410 Some(false) => " NOREPLICATION",
411 None => ""
412 },
413 bypassrls = match self.bypassrls {
414 Some(true) => " BYPASSRLS",
415 Some(false) => " NOBYPASSRLS",
416 None => ""
417 }
418 )?;
419 if let Some(limit) = &self.connection_limit {
420 write!(f, " CONNECTION LIMIT {limit}")?;
421 }
422 match &self.password {
423 Some(Password::Password(pass)) => write!(f, " PASSWORD {pass}")?,
424 Some(Password::NullPassword) => write!(f, " PASSWORD NULL")?,
425 None => {}
426 };
427 if let Some(until) = &self.valid_until {
428 write!(f, " VALID UNTIL {until}")?;
429 }
430 if !self.in_role.is_empty() {
431 write!(f, " IN ROLE {}", display_comma_separated(&self.in_role))?;
432 }
433 if !self.in_group.is_empty() {
434 write!(f, " IN GROUP {}", display_comma_separated(&self.in_group))?;
435 }
436 if !self.role.is_empty() {
437 write!(f, " ROLE {}", display_comma_separated(&self.role))?;
438 }
439 if !self.user.is_empty() {
440 write!(f, " USER {}", display_comma_separated(&self.user))?;
441 }
442 if !self.admin.is_empty() {
443 write!(f, " ADMIN {}", display_comma_separated(&self.admin))?;
444 }
445 if let Some(owner) = &self.authorization_owner {
446 write!(f, " AUTHORIZATION {owner}")?;
447 }
448 Ok(())
449 }
450}
451
452impl Spanned for CreateRole {
453 fn span(&self) -> Span {
454 Span::empty()
455 }
456}
457
458#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
460#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
461#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
462pub struct Grant {
463 pub privileges: Privileges,
465 pub objects: Option<GrantObjects>,
467 pub grantees: Vec<Grantee>,
469 pub with_grant_option: bool,
471 pub as_grantor: Option<Ident>,
473 pub granted_by: Option<Ident>,
477 pub current_grants: Option<CurrentGrantsKind>,
481}
482
483impl fmt::Display for Grant {
484 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
485 write!(f, "GRANT {privileges}", privileges = self.privileges)?;
486 if let Some(ref objects) = self.objects {
487 write!(f, " ON {objects}")?;
488 }
489 write!(f, " TO {}", display_comma_separated(&self.grantees))?;
490 if self.with_grant_option {
492 write!(f, " WITH GRANT OPTION")?;
493 }
494 if let Some(ref current_grants) = self.current_grants {
495 write!(f, " {current_grants}")?;
496 }
497 if let Some(ref as_grantor) = self.as_grantor {
498 write!(f, " AS {as_grantor}")?;
499 }
500 if let Some(ref granted_by) = self.granted_by {
501 write!(f, " GRANTED BY {granted_by}")?;
502 }
503 Ok(())
504 }
505}
506
507impl From<Grant> for crate::ast::Statement {
508 fn from(v: Grant) -> Self {
509 crate::ast::Statement::Grant(v)
510 }
511}
512
513#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
516#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
517#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
518pub struct Revoke {
519 pub grant_option_for: bool,
522 pub privileges: Privileges,
524 pub objects: Option<GrantObjects>,
526 pub grantees: Vec<Grantee>,
528 pub granted_by: Option<Ident>,
532 pub cascade: Option<CascadeOption>,
534}
535
536impl fmt::Display for Revoke {
537 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
538 write!(f, "REVOKE ")?;
539 if self.grant_option_for {
540 write!(f, "GRANT OPTION FOR ")?;
541 }
542 write!(f, "{}", self.privileges)?;
543 if let Some(ref objects) = self.objects {
544 write!(f, " ON {objects}")?;
545 }
546 write!(f, " FROM {}", display_comma_separated(&self.grantees))?;
547 if let Some(ref granted_by) = self.granted_by {
548 write!(f, " GRANTED BY {granted_by}")?;
549 }
550 if let Some(ref cascade) = self.cascade {
551 write!(f, " {cascade}")?;
552 }
553 Ok(())
554 }
555}
556
557impl From<Revoke> for crate::ast::Statement {
558 fn from(v: Revoke) -> Self {
559 crate::ast::Statement::Revoke(v)
560 }
561}
562
563#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
567#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
568#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
569pub struct RevokeRole {
570 pub option_for: Option<Ident>,
572 pub roles: Vec<Ident>,
574 pub grantees: Vec<Grantee>,
576 pub granted_by: Option<Ident>,
578 pub cascade: Option<CascadeOption>,
580}
581
582impl fmt::Display for RevokeRole {
583 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
584 write!(f, "REVOKE ")?;
585 if let Some(option_for) = &self.option_for {
586 write!(f, "{option_for} OPTION FOR ")?;
587 }
588 write!(
589 f,
590 "{} FROM {}",
591 display_comma_separated(&self.roles),
592 display_comma_separated(&self.grantees)
593 )?;
594 if let Some(granted_by) = &self.granted_by {
595 write!(f, " GRANTED BY {granted_by}")?;
596 }
597 if let Some(cascade) = &self.cascade {
598 write!(f, " {cascade}")?;
599 }
600 Ok(())
601 }
602}
603
604impl From<RevokeRole> for crate::ast::Statement {
605 fn from(v: RevokeRole) -> Self {
606 crate::ast::Statement::RevokeRole(v)
607 }
608}
609
610#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
614#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
615#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
616pub struct GrantRole {
617 pub roles: Vec<Ident>,
619 pub grantees: Vec<Grantee>,
621 pub options: Vec<RoleGrantOption>,
623 pub granted_by: Option<Ident>,
625}
626
627impl fmt::Display for GrantRole {
628 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
629 write!(
630 f,
631 "GRANT {} TO {}",
632 display_comma_separated(&self.roles),
633 display_comma_separated(&self.grantees)
634 )?;
635 if !self.options.is_empty() {
636 write!(f, " WITH {}", display_comma_separated(&self.options))?;
637 }
638 if let Some(granted_by) = &self.granted_by {
639 write!(f, " GRANTED BY {granted_by}")?;
640 }
641 Ok(())
642 }
643}
644
645impl From<GrantRole> for crate::ast::Statement {
646 fn from(v: GrantRole) -> Self {
647 crate::ast::Statement::GrantRole(v)
648 }
649}
650
651#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
653#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
654#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
655pub struct RoleGrantOption {
656 pub name: Ident,
658 pub value: RoleGrantOptionValue,
660}
661
662impl fmt::Display for RoleGrantOption {
663 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
664 write!(f, "{} {}", self.name, self.value)
665 }
666}
667
668#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
670#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
671#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
672pub enum RoleGrantOptionValue {
673 Option,
675 True,
677 False,
679}
680
681impl fmt::Display for RoleGrantOptionValue {
682 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
683 f.write_str(match self {
684 RoleGrantOptionValue::Option => "OPTION",
685 RoleGrantOptionValue::True => "TRUE",
686 RoleGrantOptionValue::False => "FALSE",
687 })
688 }
689}
690
691#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
693#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
694#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
695pub enum DefaultPrivilegesOption {
696 ForRole(Vec<Ident>),
698 InSchema(Vec<ObjectName>),
700}
701
702impl fmt::Display for DefaultPrivilegesOption {
703 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
704 match self {
705 DefaultPrivilegesOption::ForRole(roles) => {
706 write!(f, "FOR ROLE {}", display_comma_separated(roles))
707 }
708 DefaultPrivilegesOption::InSchema(schemas) => {
709 write!(f, "IN SCHEMA {}", display_comma_separated(schemas))
710 }
711 }
712 }
713}
714
715#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
720#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
721#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
722pub struct AlterDefaultPrivileges {
723 pub options: Vec<DefaultPrivilegesOption>,
725 pub operation: AlterDefaultPrivilegesOperation,
727}
728
729impl fmt::Display for AlterDefaultPrivileges {
730 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
731 f.write_str("ALTER DEFAULT PRIVILEGES")?;
732 for option in &self.options {
733 write!(f, " {option}")?;
734 }
735 write!(f, " {}", self.operation)
736 }
737}
738
739impl Spanned for AlterDefaultPrivileges {
740 fn span(&self) -> Span {
741 let options = self.options.iter().map(|option| match option {
742 DefaultPrivilegesOption::ForRole(roles) => {
743 Span::union_iter(roles.iter().map(|role| role.span))
744 }
745 DefaultPrivilegesOption::InSchema(schemas) => {
746 Span::union_iter(schemas.iter().map(Spanned::span))
747 }
748 });
749 let grantees = match &self.operation {
750 AlterDefaultPrivilegesOperation::Grant { grantees, .. }
751 | AlterDefaultPrivilegesOperation::Revoke { grantees, .. } => grantees,
752 };
753 Span::union_iter(
754 options.chain(
755 grantees
756 .iter()
757 .filter_map(|grantee| grantee.name.as_ref())
758 .map(|name| match name {
759 GranteeName::ObjectName(name) => name.span(),
760 GranteeName::UserHost { user, host } => user.span.union(&host.span),
761 }),
762 ),
763 )
764 }
765}
766
767impl From<AlterDefaultPrivileges> for crate::ast::Statement {
768 fn from(v: AlterDefaultPrivileges) -> Self {
769 crate::ast::Statement::AlterDefaultPrivileges(v)
770 }
771}
772
773#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
776#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
777#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
778pub enum AlterDefaultPrivilegesOperation {
779 Grant {
781 privileges: Privileges,
783 object_type: DefaultPrivilegesObjectType,
785 grantees: Vec<Grantee>,
787 with_grant_option: bool,
789 },
790 Revoke {
792 grant_option_for: bool,
794 privileges: Privileges,
796 object_type: DefaultPrivilegesObjectType,
798 grantees: Vec<Grantee>,
800 cascade: Option<CascadeOption>,
802 },
803}
804
805impl fmt::Display for AlterDefaultPrivilegesOperation {
806 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
807 match self {
808 AlterDefaultPrivilegesOperation::Grant {
809 privileges,
810 object_type,
811 grantees,
812 with_grant_option,
813 } => {
814 write!(
815 f,
816 "GRANT {privileges} ON {object_type} TO {}",
817 display_comma_separated(grantees)
818 )?;
819 if *with_grant_option {
820 f.write_str(" WITH GRANT OPTION")?;
821 }
822 }
823 AlterDefaultPrivilegesOperation::Revoke {
824 grant_option_for,
825 privileges,
826 object_type,
827 grantees,
828 cascade,
829 } => {
830 f.write_str("REVOKE ")?;
831 if *grant_option_for {
832 f.write_str("GRANT OPTION FOR ")?;
833 }
834 write!(
835 f,
836 "{privileges} ON {object_type} FROM {}",
837 display_comma_separated(grantees)
838 )?;
839 if let Some(cascade) = cascade {
840 write!(f, " {cascade}")?;
841 }
842 }
843 }
844 Ok(())
845 }
846}
847
848#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
850#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
851#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
852pub enum DefaultPrivilegesObjectType {
853 Tables,
855 Sequences,
857 Functions,
859 Routines,
861 Types,
863 Schemas,
865 LargeObjects,
867}
868
869impl fmt::Display for DefaultPrivilegesObjectType {
870 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
871 f.write_str(match self {
872 DefaultPrivilegesObjectType::Tables => "TABLES",
873 DefaultPrivilegesObjectType::Sequences => "SEQUENCES",
874 DefaultPrivilegesObjectType::Functions => "FUNCTIONS",
875 DefaultPrivilegesObjectType::Routines => "ROUTINES",
876 DefaultPrivilegesObjectType::Types => "TYPES",
877 DefaultPrivilegesObjectType::Schemas => "SCHEMAS",
878 DefaultPrivilegesObjectType::LargeObjects => "LARGE OBJECTS",
879 })
880 }
881}