pgrx_catalog/lib.rs
1use pg_sys::Oid as Regproc;
2use pg_sys::Oid;
3use pgrx::datum::Array;
4use pgrx::pg_sys;
5use std::ffi::{CStr, c_char};
6use std::ptr::NonNull;
7
8trait GetStruct<T> {
9 /// # Safety
10 ///
11 /// `raw` must be a refernece to a struct member in `FormData_*`.
12 unsafe fn get_struct(raw: T) -> Self;
13}
14
15impl<'a, T: Copy> GetStruct<&'a T> for T {
16 unsafe fn get_struct(raw: &'a T) -> Self {
17 *raw
18 }
19}
20
21// PostgreSQL comments:
22// Representation of a Name: effectively just a C string, but null-padded to exactly NAMEDATALEN bytes.
23// The use of a struct is historical.
24impl<'a> GetStruct<&'a pg_sys::nameData> for &'a CStr {
25 unsafe fn get_struct(raw: &pg_sys::nameData) -> Self {
26 assert_eq!(raw.data[63], 0);
27 unsafe { CStr::from_ptr(raw.data.as_ptr()) }
28 }
29}
30
31// A variable-sized type that is always the last struct member in `FormData_*`.
32impl<'a> GetStruct<&'a pg_sys::int2vector> for &'a [i16] {
33 unsafe fn get_struct(raw: &'a pg_sys::int2vector) -> Self {
34 let len = raw.dim1;
35 // SAFETY: we trust `len` since it's passed from PostgreSQL and we cannot check it anyway.
36 unsafe { raw.values.as_slice(len as usize) }
37 }
38}
39
40// A variable-sized type that is always the last struct member in `FormData_*`.
41impl<'a> GetStruct<&'a pg_sys::oidvector> for &'a [Oid] {
42 unsafe fn get_struct(raw: &'a pg_sys::oidvector) -> Self {
43 let len = raw.dim1;
44 // SAFETY: we trust `len` since it's passed from PostgreSQL and we cannot check it anyway.
45 unsafe { raw.values.as_slice(len as usize) }
46 }
47}
48
49#[inline]
50unsafe fn get_struct<T>(inner: &pg_sys::HeapTupleData) -> &T {
51 debug_assert!(std::any::type_name::<T>().contains("FormData_"));
52 unsafe {
53 // PostgreSQL macro `GETSTRUCT(tup)` expands to `((char *)((tup)->t_data) + (tup)->t_data->t_hoff)`.
54 let start = inner.t_data.cast::<u8>();
55 let offset: u8 = (*inner.t_data).t_hoff;
56 // So `s` is deferenced `GETSTRUCT(tup)`.
57 &*start.add(offset as usize).cast::<T>()
58 }
59}
60
61#[inline]
62unsafe fn get_attr<T: pgrx::datum::FromDatum>(
63 inner: *const pg_sys::HeapTupleData,
64 cache_id: i32,
65 attribute: u32,
66) -> Option<T> {
67 unsafe {
68 let arg_tup = inner.cast_mut();
69 let arg_att = attribute as i16;
70 let mut is_null = true;
71 let datum = pg_sys::SysCacheGetAttr(cache_id, arg_tup, arg_att, &mut is_null);
72 T::from_datum(datum, is_null)
73 }
74}
75
76#[inline]
77unsafe fn syscache_len(inner: NonNull<pg_sys::CatCList>) -> usize {
78 unsafe {
79 use pg_sys::CatCList;
80 let inner: &CatCList = inner.as_ref();
81 let n: i32 = inner.n_members;
82 n as usize
83 }
84}
85
86#[inline]
87unsafe fn syscache_get<'a>(
88 inner: NonNull<pg_sys::CatCList>,
89 i: usize,
90) -> Option<&'a pg_sys::HeapTupleData> {
91 unsafe {
92 use pg_sys::{CatCList, CatCTup, HeapTupleData};
93 let inner: &CatCList = inner.as_ref();
94 let n: i32 = inner.n_members;
95 let slice: &[*mut CatCTup] = inner.members.as_slice(n as usize);
96 let member: *mut CatCTup = *slice.get(i)?;
97 let tuple: &HeapTupleData = &(*member).tuple;
98 Some(tuple)
99 }
100}
101
102macro_rules! define_character {
103 {
104 $(#[$character_meta:meta])* character ($table:ident, $column:ident) { $($(#[$variant_meta:meta])* ($variant:ident, $variant_value:literal))* }
105 } => {
106 paste::paste! {
107 #[doc = concat!("Enum for pg_catalog.", stringify!($table), ".", stringify!($column), ".")]
108 $(#[$character_meta])*
109 #[non_exhaustive]
110 #[repr(u8)]
111 #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
112 pub enum [<$table:camel $column:camel>] {
113 $($(#[$variant_meta])* $variant = $variant_value),*
114 }
115
116 impl [<$table:camel $column:camel>] {
117 pub fn new(value: c_char) -> Option<Self> {
118 #[allow(unused_doc_comments)]
119 match value as u8 {
120 $($(#[$variant_meta])* $variant_value => Some(Self::$variant),)*
121 _ => None,
122 }
123 }
124 pub fn as_c_char(self) -> c_char {
125 self as u8 as c_char
126 }
127 }
128
129 impl pgrx::datum::FromDatum for [<$table:camel $column:camel>] {
130 unsafe fn from_polymorphic_datum(
131 datum: pg_sys::Datum,
132 is_null: bool,
133 _: Oid,
134 ) -> Option<Self>
135 where
136 Self: Sized,
137 {
138 if is_null {
139 None
140 } else {
141 Some(Self::new(datum.value() as _).expect("unrecognized value"))
142 }
143 }
144 }
145
146 impl pgrx::datum::IntoDatum for [<$table:camel $column:camel>] {
147 fn into_datum(self) -> std::option::Option<pg_sys::Datum> {
148 Some(pg_sys::Datum::from(self as i8))
149 }
150 fn type_oid() -> pg_sys::Oid {
151 pg_sys::CHAROID
152 }
153 }
154
155 unsafe impl pgrx::datum::UnboxDatum for [<$table:camel $column:camel>] {
156 type As<'src> = Self;
157 #[inline]
158 unsafe fn unbox<'src>(datum: pgrx::datum::Datum<'src>) -> Self::As<'src>
159 where
160 Self: 'src,
161 {
162 Self::new(datum.sans_lifetime().value() as c_char).expect("unrecognized value")
163 }
164 }
165
166 impl<'a> GetStruct<&'a c_char> for [<$table:camel $column:camel>] {
167 unsafe fn get_struct(raw: &c_char) -> Self {
168 Self::new(*raw).expect("unrecognized value")
169 }
170 }
171 }
172 };
173}
174
175macro_rules! define_column {
176 {
177 $(#[$column_meta:meta])* column ($table:ident, $column:ident, $column_type:ty, $(#[$character_meta:meta])* character { $($(#[$variant_meta:meta])* ($variant:ident, $variant_value:literal))* } $($x:tt)*)
178 } => {
179 paste::paste! {
180 define_character! { $(#[$character_meta])* character ($table, $column) { $($(#[$variant_meta])* ($variant, $variant_value))* } }
181 define_column! { $(#[$column_meta])* column ($table, $column, $column_type $($x)*) }
182 }
183 };
184 {
185 $(#[$column_meta:meta])* column ($table:ident, $column:ident, $column_type:ty, get_struct)
186 } => {
187 paste::paste! {
188 impl [<$table:camel>]<'_> {
189 $(#[$column_meta])*
190 pub fn $column(&self) -> $column_type {
191 unsafe {
192 let s = get_struct::<pg_sys::[<FormData_ $table>]>(self.inner);
193 // SAFETY: we get `s` from PostgreSQL functions.
194 GetStruct::get_struct(&s.$column)
195 }
196 }
197 }
198 }
199 };
200 {
201 $(#[$column_meta:meta])* column ($table:ident, $column:ident, $column_type:ty, get_attr)
202 } => {
203 paste::paste! {
204 impl [<$table:camel>]<'_> {
205 $(#[$column_meta])*
206 pub fn $column(&self) -> Option<$column_type> {
207 unsafe {
208 get_attr::<$column_type>(self.inner, self.cache_id, pg_sys::[<Anum_ $table _ $column>])
209 }
210 }
211 }
212 }
213 };
214 {
215 $(#[$column_meta:meta])* column ($table:ident, $column:ident, $column_type:ty, get_attr_notnull)
216 } => {
217 paste::paste! {
218 impl [<$table:camel>]<'_> {
219 $(#[$column_meta])*
220 pub fn $column(&self) -> $column_type {
221 unsafe {
222 get_attr::<$column_type>(self.inner, self.cache_id, pg_sys::[<Anum_ $table _ $column>])
223 }.unwrap()
224 }
225 }
226 }
227 };
228}
229
230macro_rules! define_catalog {
231 {
232 $(#[$table_meta:meta])* catalog ($table:ident) { $($(#[$column_meta:meta])* ($column:ident, $column_type:ty, $($x:tt)*))* }
233 } => {
234 paste::paste!{
235 #[doc = concat!("Safe wrapper for pg_catalog.", stringify!($table), ".")]
236 $(#[$table_meta])*
237 pub struct [<$table:camel>]<'a> {
238 inner: &'a pg_sys::HeapTupleData,
239 #[allow(dead_code)]
240 cache_id: i32,
241 }
242
243 #[doc = concat!("The search result for pg_catalog.", stringify!($table), ".")]
244 pub struct [<$table:camel Search>] {
245 inner: Option<NonNull<pg_sys::HeapTupleData>>,
246 cache_id: i32,
247 }
248
249 impl [<$table:camel Search>] {
250 /// Returns true if the search result is empty.
251 pub fn is_empty(&self) -> bool {
252 self.inner.is_none()
253 }
254 /// Get the search result.
255 pub fn get(&self) -> Option<[<$table:camel>]<'_>> {
256 unsafe {
257 Some([<$table:camel>] {
258 inner: self.inner?.as_ref(),
259 cache_id: self.cache_id,
260 })
261 }
262 }
263 }
264
265 impl Drop for [<$table:camel Search>] {
266 fn drop(&mut self) {
267 unsafe {
268 if let Some(inner) = self.inner {
269 pg_sys::ReleaseSysCache(inner.as_ptr());
270 }
271 }
272 }
273 }
274
275 #[doc = concat!("The search results for pg_catalog.", stringify!($table), ".")]
276 pub struct [<$table:camel SearchList>] {
277 inner: NonNull<pg_sys::CatCList>,
278 cache_id: i32,
279 }
280
281 impl [<$table:camel SearchList>] {
282 /// Returns the number of the search results.
283 pub fn len(&self) -> usize {
284 unsafe {
285 syscache_len(self.inner)
286 }
287 }
288 /// Returns true if the search result is empty.
289 pub fn is_empty(&self) -> bool {
290 self.len() == 0
291 }
292 /// Get the `i`-th search result.
293 pub fn get(&self, i: usize) -> Option<[<$table:camel>]<'_>> {
294 unsafe {
295 Some([<$table:camel>] {
296 inner: syscache_get(self.inner, i)?,
297 cache_id: self.cache_id
298 })
299 }
300 }
301 }
302
303 impl Drop for [<$table:camel SearchList>] {
304 fn drop(&mut self) {
305 unsafe { pg_sys::ReleaseCatCacheList(self.inner.as_ptr()) }
306 }
307 }
308
309 $(define_column! { $(#[$column_meta])* column ($table, $column, $column_type, $($x)*) })*
310 }
311 };
312}
313
314macro_rules! define_cache {
315 {
316 cache ($cache:ident, $table:ident) {
317 ($_0:ident, $_0_type:ty)
318 }
319 } => {
320 paste::paste!{
321 impl<'a> [<$table:camel>]<'a> {
322 /// Search for a row by providing arguments needed by cache.
323 pub fn [<search _ $cache>]($_0: $_0_type) -> Option<[<$table:camel Search>]> {
324 use pgrx::datum::IntoDatum;
325 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
326 let entry = unsafe { pg_sys::SearchSysCache1(cache_id, $_0.into_datum()?) };
327 let inner = NonNull::new(entry);
328 Some([<$table:camel Search>] { inner, cache_id })
329 }
330 }
331 }
332 };
333 {
334 cache ($cache:ident, $table:ident) {
335 ($_0:ident, $_0_type:ty)
336 ($_1:ident, $_1_type:ty)
337 }
338 } => {
339 paste::paste!{
340 impl<'a> [<$table:camel>]<'a> {
341 /// Search for a row by providing arguments needed by cache.
342 pub fn [<search _ $cache>]($_0: $_0_type, $_1: $_1_type) -> Option<[<$table:camel Search>]> {
343 use pgrx::datum::IntoDatum;
344 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
345 let entry = unsafe {
346 pg_sys::SearchSysCache2(
347 cache_id,
348 $_0.into_datum()?,
349 $_1.into_datum()?,
350 )
351 };
352 let inner = NonNull::new(entry);
353 Some([<$table:camel Search>] { inner, cache_id })
354 }
355 /// Search for rows by providing first 1 argument needed by cache.
356 pub fn [<search _list_ $cache _1>]($_0: $_0_type) -> Option<[<$table:camel SearchList>]> {
357 use pgrx::datum::IntoDatum;
358 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
359 let entry = unsafe {
360 pg_sys::SearchSysCacheList(
361 cache_id,
362 1,
363 $_0.into_datum()?,
364 0.into(),
365 0.into(),
366 )
367 };
368 let inner = NonNull::new(entry).unwrap();
369 Some([<$table:camel SearchList>] { inner, cache_id })
370 }
371 }
372 }
373 };
374 {
375 cache ($cache:ident, $table:ident) {
376 ($_0:ident, $_0_type:ty)
377 ($_1:ident, $_1_type:ty)
378 ($_2:ident, $_2_type:ty)
379 }
380 } => {
381 paste::paste!{
382 impl<'a> [<$table:camel>]<'a> {
383 /// Search for a row by providing arguments needed by cache.
384 pub fn [<search _ $cache>]($_0: $_0_type, $_1: $_1_type, $_2: $_2_type) -> Option<[<$table:camel Search>]> {
385 use pgrx::datum::IntoDatum;
386 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
387 let entry = unsafe {
388 pg_sys::SearchSysCache3(
389 cache_id,
390 $_0.into_datum()?,
391 $_1.into_datum()?,
392 $_2.into_datum()?,
393 )
394 };
395 let inner = NonNull::new(entry);
396 Some([<$table:camel Search>] { inner, cache_id })
397 }
398 /// Search for rows by providing first 1 argument needed by cache.
399 pub fn [<search _list_ $cache _1>]($_0: $_0_type) -> Option<[<$table:camel SearchList>]> {
400 use pgrx::datum::IntoDatum;
401 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
402 let entry = unsafe {
403 pg_sys::SearchSysCacheList(
404 cache_id,
405 1,
406 $_0.into_datum()?,
407 0.into(),
408 0.into(),
409 )
410 };
411 let inner = NonNull::new(entry).unwrap();
412 Some([<$table:camel SearchList>] { inner, cache_id })
413 }
414 /// Search for rows by providing first 2 arguments needed by cache.
415 pub fn [<search _list_ $cache _2>]($_0: $_0_type, $_1: $_1_type) -> Option<[<$table:camel SearchList>]> {
416 use pgrx::datum::IntoDatum;
417 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
418 let entry = unsafe {
419 pg_sys::SearchSysCacheList(
420 cache_id,
421 2,
422 $_0.into_datum()?,
423 $_1.into_datum()?,
424 0.into(),
425 )
426 };
427 let inner = NonNull::new(entry).unwrap();
428 Some([<$table:camel SearchList>] { inner, cache_id })
429 }
430 }
431 }
432 };
433 {
434 cache ($cache:ident, $table:ident) {
435 ($_0:ident, $_0_type:ty)
436 ($_1:ident, $_1_type:ty)
437 ($_2:ident, $_2_type:ty)
438 ($_3:ident, $_3_type:ty)
439 }
440 } => {
441 paste::paste!{
442 impl<'a> [<$table:camel>]<'a> {
443 /// Search for a row by providing arguments needed by cache.
444 pub fn [<search _ $cache>]($_0: $_0_type, $_1: $_1_type, $_2: $_2_type, $_3: $_3_type) -> Option<[<$table:camel Search>]> {
445 use pgrx::datum::IntoDatum;
446 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
447 let entry = unsafe {
448 pg_sys::SearchSysCache4(
449 cache_id,
450 $_0.into_datum()?,
451 $_1.into_datum()?,
452 $_2.into_datum()?,
453 $_3.into_datum()?,
454 )
455 };
456 let inner = NonNull::new(entry);
457 Some([<$table:camel Search>] { inner, cache_id })
458 }
459 /// Search for rows by providing first 1 argument needed by cache.
460 pub fn [<search _list_ $cache _1>]($_0: $_0_type) -> Option<[<$table:camel SearchList>]> {
461 use pgrx::datum::IntoDatum;
462 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
463 let entry = unsafe {
464 pg_sys::SearchSysCacheList(
465 cache_id,
466 1,
467 $_0.into_datum()?,
468 0.into(),
469 0.into(),
470 )
471 };
472 let inner = NonNull::new(entry).unwrap();
473 Some([<$table:camel SearchList>] { inner, cache_id })
474 }
475 /// Search for rows by providing first 2 arguments needed by cache.
476 pub fn [<search _list_ $cache _2>]($_0: $_0_type, $_1: $_1_type) -> Option<[<$table:camel SearchList>]> {
477 use pgrx::datum::IntoDatum;
478 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
479 let entry = unsafe {
480 pg_sys::SearchSysCacheList(
481 cache_id,
482 2,
483 $_0.into_datum()?,
484 $_1.into_datum()?,
485 0.into(),
486 )
487 };
488 let inner = NonNull::new(entry).unwrap();
489 Some([<$table:camel SearchList>] { inner, cache_id })
490 }
491 /// Search for rows by providing first 3 arguments needed by cache.
492 pub fn [<search _list_ $cache _3>]($_0: $_0_type, $_1: $_1_type, $_2: $_2_type) -> Option<[<$table:camel SearchList>]> {
493 use pgrx::datum::IntoDatum;
494 let cache_id = pg_sys::SysCacheIdentifier::[<$cache:upper>] as i32;
495 let entry = unsafe {
496 pg_sys::SearchSysCacheList(
497 cache_id,
498 3,
499 $_0.into_datum()?,
500 $_1.into_datum()?,
501 $_2.into_datum()?,
502 )
503 };
504 let inner = NonNull::new(entry).unwrap();
505 Some([<$table:camel SearchList>] { inner, cache_id })
506 }
507 }
508 }
509 };
510}
511
512define_catalog! {
513 /// The catalog pg_am stores information about relation access methods. There is one row for each access method supported by the system. Currently, only tables and indexes have access methods.
514 catalog (pg_am) {
515 /// Row identifier.
516 (oid, Oid, get_struct)
517 /// Name of the access method.
518 (amname, &CStr, get_struct)
519 /// OID of a handler function that is responsible for supplying information about the access method.
520 (amhandler, Regproc, get_struct)
521 (amtype, PgAmAmtype, character {
522 /// t = table (including materialized views)
523 (Table, b't')
524 /// i = index
525 (Index, b'i')
526 }, get_struct)
527 }
528}
529
530define_catalog! {
531 /// The catalog pg_amop stores information about operators associated with access method operator families. There is one row for each operator that is a member of an operator family. A family member can be either a search operator or an ordering operator. An operator can appear in more than one family, but cannot appear in more than one search position nor more than one ordering position within a family. (It is allowed, though unlikely, for an operator to be used for both search and ordering purposes.)
532 catalog (pg_amop) {
533 /// Row identifier.
534 (oid, Oid, get_struct)
535 /// The operator family this entry is for.
536 (amopfamily, Oid, get_struct)
537 /// Left-hand input data type of operator.
538 (amoplefttype, Oid, get_struct)
539 /// Right-hand input data type of operator.
540 (amoprighttype, Oid, get_struct)
541 /// Operator strategy number.
542 (amopstrategy, i16, get_struct)
543 /// Operator purpose.
544 (amoppurpose, PgAmopAmoppurpose, character {
545 /// s for search
546 (Search, b's')
547 /// o for ordering
548 (Order, b'o')
549 }, get_struct)
550 /// OID of the operator.
551 (amopopr, Oid, get_struct)
552 /// Index access method operator family is for.
553 (amopmethod, Oid, get_struct)
554 /// The B-tree operator family this entry sorts according to, if an ordering operator; zero if a search operator.
555 (amopsortfamily, Oid, get_struct)
556 }
557}
558
559define_catalog! {
560 /// The catalog pg_amproc stores information about support functions associated with access method operator families. There is one row for each support function belonging to an operator family.
561 catalog (pg_amproc) {
562 /// Row identifier.
563 (oid, Oid, get_struct)
564 /// The operator family this entry is for.
565 (amprocfamily, Oid, get_struct)
566 /// Left-hand input data type of associated operator.
567 (amproclefttype, Oid, get_struct)
568 /// Right-hand input data type of associated operator.
569 (amprocrighttype, Oid, get_struct)
570 /// Support function number.
571 (amprocnum, i16, get_struct)
572 /// OID of the function.
573 (amproc, Regproc, get_struct)
574 }
575}
576
577define_catalog! {
578 /// The catalog pg_class describes tables and other objects that have columns or are otherwise similar to a table. This includes indexes, sequences, views, materialized views, composite types, and TOAST tables; see relkind. Below, when we mean all of these kinds of objects we speak of “relations”. Not all of pg_class's columns are meaningful for all relation kinds.
579 catalog (pg_class) {
580 /// Row identifier.
581 (oid, Oid, get_struct)
582 /// Name of the table, index, view, etc.
583 (relname, &CStr, get_struct)
584 /// The OID of the namespace that contains this relation.
585 (relnamespace, Oid, get_struct)
586 /// The OID of the data type that corresponds to this table's row type, if any; zero for indexes, sequences, and toast tables, which have no pg_type entry.
587 (reltype, Oid, get_struct)
588 /// For typed tables, the OID of the underlying composite type; zero for all other relations.
589 (reloftype, Oid, get_struct)
590 /// Owner of the relation.
591 (relowner, Oid, get_struct)
592 /// If this is a table or an index, the access method used (heap, B-tree, hash, etc.); otherwise zero (zero occurs for sequences, as well as relations without storage, such as views).
593 (relam, Oid, get_struct)
594 /// Name of the on-disk file of this relation; zero means this is a “mapped” relation whose disk file name is determined by low-level state.
595 (relfilenode, Oid, get_struct)
596 /// The tablespace in which this relation is stored. If zero, the database's default tablespace is implied. (Not meaningful if the relation has no on-disk file.)
597 (reltablespace, Oid, get_struct)
598 /// Size of the on-disk representation of this table in pages (of size BLCKSZ). This is only an estimate used by the planner. It is updated by VACUUM, ANALYZE, and a few DDL commands such as `CREATE INDEX`.
599 (relpages, i32, get_struct)
600 /// Number of live rows in the table. This is only an estimate used by the planner. It is updated by VACUUM, ANALYZE, and a few DDL commands such as `CREATE INDEX`. If the table has never yet been vacuumed or analyzed, reltuples contains -1 indicating that the row count is unknown.
601 (reltuples, f32, get_struct)
602 /// Number of pages that are marked all-visible in the table's visibility map. This is only an estimate used by the planner. It is updated by VACUUM, ANALYZE, and a few DDL commands such as `CREATE INDEX`.
603 (relallvisible, i32, get_struct)
604 /// OID of the TOAST table associated with this table, zero if none. The TOAST table stores large attributes “out of line” in a secondary table.
605 (reltoastrelid, Oid, get_struct)
606 /// True if this is a table and it has (or recently had) any indexes.
607 (relhasindex, bool, get_struct)
608 /// True if this table is shared across all databases in the cluster. Only certain system catalogs (such as pg_database) are shared.
609 (relisshared, bool, get_struct)
610 (relpersistence, PgClassRelpersistence, character {
611 /// p = permanent table/sequence
612 (Permanent, b'p')
613 /// u = unlogged table/sequence
614 (Unlogged, b'u')
615 /// t = temporary table/sequence
616 (Temp, b't')
617 }, get_struct)
618 (relkind, PgClassRelkind, character {
619 /// r = ordinary table
620 (Relation, b'r')
621 /// i = index
622 (Index, b'i')
623 /// S = sequence
624 (Sequence, b'S')
625 /// t = TOAST table
626 (Toastvalue, b't')
627 /// v = view
628 (View, b'v')
629 /// m = materialized view
630 (Matview, b'm')
631 /// c = composite type
632 (CompositeType, b'c')
633 /// f = foreign table
634 (ForeignTable, b'f')
635 /// p = partitioned table
636 (PartitionedTable, b'p')
637 /// I = partitioned index
638 (PartitionedIndex, b'I')
639 #[cfg(feature = "pg19")]
640 /// g = property graph
641 (PropertyGraph, b'g')
642 }, get_struct)
643 /// Number of user columns in the relation (system columns not counted). There must be this many corresponding entries in pg_attribute.
644 (relnatts, i16, get_struct)
645 /// Number of `CHECK` constraints on the table.
646 (relchecks, i16, get_struct)
647 /// True if table has (or once had) rules.
648 (relhasrules, bool, get_struct)
649 /// True if table has (or once had) triggers.
650 (relhastriggers, bool, get_struct)
651 /// True if table or index has (or once had) any inheritance children or partitions.
652 (relhassubclass, bool, get_struct)
653 /// True if table has row-level security enabled.
654 (relrowsecurity, bool, get_struct)
655 /// True if row-level security (when enabled) will also apply to table owner.
656 (relforcerowsecurity, bool, get_struct)
657 /// True if relation is populated (this is true for all relations other than some materialized views).
658 (relispopulated, bool, get_struct)
659 /// Columns used to form “replica identity” for rows.
660 (relreplident, PgClassRelreplident, character {
661 /// d = default (primary key, if any)
662 (Default, b'd')
663 /// n = nothing
664 (Nothing, b'n')
665 /// f = all columns
666 (Full, b'f')
667 /// i = index with indisreplident set (same as nothing if the index used has been dropped)
668 (Index, b'i')
669 }, get_struct)
670 /// True if table or index is a partition.
671 (relispartition, bool, get_struct)
672 /// For new relations being written during a DDL operation that requires a table rewrite, this contains the OID of the original relation; otherwise zero. That state is only visible internally; this field should never contain anything other than zero for a user-visible relation.
673 (relrewrite, Oid, get_struct)
674 /// All transaction IDs before this one have been replaced with a permanent (“frozen”) transaction ID in this table. This is used to track whether the table needs to be vacuumed in order to prevent transaction ID wraparound or to allow pg_xact to be shrunk. Zero (InvalidTransactionId) if the relation is not a table.
675 (relfrozenxid, pg_sys::TransactionId, get_struct)
676 /// All multixact IDs before this one have been replaced by a transaction ID in this table. This is used to track whether the table needs to be vacuumed in order to prevent multixact ID wraparound or to allow pg_multixact to be shrunk. Zero (InvalidMultiXactId) if the relation is not a table.
677 (relminmxid, pg_sys::TransactionId, get_struct)
678 // (relacl, aclitem[], get_attr)
679 /// Access-method-specific options, as “keyword=value” strings.
680 (reloptions, Array<'_, String>, get_attr)
681 // (relpartbound, pg_node_tree, get_attr)
682 }
683}
684
685define_catalog! {
686 /// The pg_enum catalog contains entries showing the values and labels for each enum type. The internal representation of a given enum value is actually the OID of its associated row in pg_enum.
687 catalog (pg_enum) {
688 /// Row identifier.
689 (oid, Oid, get_struct)
690 /// The OID of the pg_type entry owning this enum value.
691 (enumtypid, Oid, get_struct)
692 /// The sort position of this enum value within its enum type.
693 (enumsortorder, f32, get_struct)
694 /// The textual label for this enum value.
695 (enumlabel, &CStr, get_struct)
696 }
697}
698
699define_catalog! {
700 /// The catalog pg_index contains part of the information about indexes. The rest is mostly in pg_class.
701 catalog (pg_index) {
702 /// The OID of the pg_class entry for this index.
703 (indexrelid, Oid, get_struct)
704 /// The OID of the pg_class entry for the table this index is for.
705 (indrelid, Oid, get_struct)
706 /// The total number of columns in the index (duplicates pg_class.relnatts); this number includes both key and included attributes.
707 (indnatts, i16, get_struct)
708 /// The number of key columns in the index, not counting any included columns, which are merely stored and do not participate in the index semantics.
709 (indnkeyatts, i16, get_struct)
710 /// If true, this is a unique index.
711 (indisunique, bool, get_struct)
712 #[cfg(any(feature = "pg15", feature = "pg16", feature = "pg17", feature = "pg18", feature = "pg19"))]
713 /// This value is only used for unique indexes. If false, this unique index will consider null values distinct (so the index can contain multiple null values in a column, the default PostgreSQL behavior). If it is true, it will consider null values to be equal (so the index can only contain one null value in a column).
714 (indnullsnotdistinct, bool, get_struct)
715 /// If true, this index represents the primary key of the table (indisunique should always be true when this is true).
716 (indisprimary, bool, get_struct)
717 /// If true, this index supports an exclusion constraint.
718 (indisexclusion, bool, get_struct)
719 /// If true, the uniqueness check is enforced immediately on insertion (irrelevant if indisunique is not true).
720 (indimmediate, bool, get_struct)
721 /// If true, the table was last clustered on this index.
722 (indisclustered, bool, get_struct)
723 /// If true, the index is currently valid for queries. False means the index is possibly incomplete: it must still be modified by INSERT/UPDATE operations, but it cannot safely be used for queries. If it is unique, the uniqueness property is not guaranteed true either.
724 (indisvalid, bool, get_struct)
725 /// If true, queries must not use the index until the xmin of this pg_index row is below their TransactionXmin event horizon, because the table may contain broken HOT chains with incompatible rows that they can see.
726 (indcheckxmin, bool, get_struct)
727 /// If true, the index is currently ready for inserts. False means the index must be ignored by INSERT/UPDATE operations.
728 (indisready, bool, get_struct)
729 /// If false, the index is in process of being dropped, and should be ignored for all purposes (including HOT-safety decisions).
730 (indislive, bool, get_struct)
731 /// If true this index has been chosen as “replica identity” using `ALTER TABLE ... REPLICA IDENTITY USING INDEX ...`.
732 (indisreplident, bool, get_struct)
733 /// This is an array of indnatts values that indicate which table columns this index indexes. For example, a value of 1 3 would mean that the first and the third table columns make up the index entries. Key columns come before non-key (included) columns. A zero in this array indicates that the corresponding index attribute is an expression over the table columns, rather than a simple column reference.
734 (indkey, &[i16], get_struct)
735 /// For each column in the index key (indnkeyatts values), this contains the OID of the collation to use for the index, or zero if the column is not of a collatable data type.
736 (indcollation, Array<'_, Oid>, get_attr_notnull)
737 /// For each column in the index key (indnkeyatts values), this contains the OID of the operator class to use. See pg_opclass for details.
738 (indclass, Array<'_, Oid>, get_attr_notnull)
739 /// This is an array of indnkeyatts values that store per-column flag bits. The meaning of the bits is defined by the index's access method.
740 (indoption, Array<'_, i16>, get_attr_notnull)
741 // (indexprs, pg_node_tree, get_attr)
742 // (indpred, pg_node_tree, get_attr)
743 }
744}
745
746define_catalog! {
747 /// The catalog pg_namespace stores namespaces. A namespace is the structure underlying SQL schemas: each namespace can have a separate collection of relations, types, etc. without name conflicts.
748 catalog (pg_namespace) {
749 /// Row identifier.
750 (oid, Oid, get_struct)
751 /// Name of the namespace.
752 (nspname, &CStr, get_struct)
753 /// Owner of the namespace.
754 (nspowner, Oid, get_struct)
755 // (nspacl, aclitem[], get_attr)
756 }
757}
758
759define_catalog! {
760 /// The catalog pg_opclass defines index access method operator classes. Each operator class defines semantics for index columns of a particular data type and a particular index access method. An operator class essentially specifies that a particular operator family is applicable to a particular indexable column data type. The set of operators from the family that are actually usable with the indexed column are whichever ones accept the column's data type as their left-hand input.
761 catalog (pg_opclass) {
762 /// Row identifier.
763 (oid, Oid, get_struct)
764 /// Index access method operator class is for.
765 (opcmethod, Oid, get_struct)
766 /// Name of this operator class.
767 (opcname, &CStr, get_struct)
768 /// Namespace of this operator class.
769 (opcnamespace, Oid, get_struct)
770 /// Owner of the operator class.
771 (opcowner, Oid, get_struct)
772 /// Operator family containing the operator class.
773 (opcfamily, Oid, get_struct)
774 /// Data type that the operator class indexes.
775 (opcintype, Oid, get_struct)
776 /// True if this operator class is the default for opcintype.
777 (opcdefault, bool, get_struct)
778 /// Type of data stored in index, or zero if same as opcintype.
779 (opckeytype, Oid, get_struct)
780 }
781}
782
783define_catalog! {
784 /// The catalog pg_operator stores information about operators.
785 catalog (pg_operator) {
786 /// Row identifier.
787 (oid, Oid, get_struct)
788 /// Name of the operator.
789 (oprname, &CStr, get_struct)
790 /// The OID of the namespace that contains this operator.
791 (oprnamespace, Oid, get_struct)
792 /// Owner of the operator.
793 (oprowner, Oid, get_struct)
794 (oprkind, PgOperatorOprkind, character {
795 /// b = infix operator (“both”)
796 (Infix, b'b')
797 /// l = prefix operator (“left”)
798 (Prefix, b'l')
799 }, get_struct)
800 /// This operator supports merge joins.
801 (oprcanmerge, bool, get_struct)
802 /// This operator supports hash joins.
803 (oprcanhash, bool, get_struct)
804 /// Type of the left operand (zero for a prefix operator).
805 (oprleft, Oid, get_struct)
806 /// Type of the right operand
807 (oprright, Oid, get_struct)
808 /// Type of the result (zero for a not-yet-defined “shell” operator).
809 (oprresult, Oid, get_struct)
810 /// Commutator of this operator (zero if none).
811 (oprcom, Oid, get_struct)
812 /// Negator of this operator (zero if none).
813 (oprnegate, Oid, get_struct)
814 /// Function that implements this operator (zero for a not-yet-defined “shell” operator).
815 (oprcode, Regproc, get_struct)
816 /// Restriction selectivity estimation function for this operator (zero if none).
817 (oprrest, Regproc, get_struct)
818 /// Join selectivity estimation function for this operator (zero if none).
819 (oprjoin, Regproc, get_struct)
820 }
821}
822
823define_catalog! {
824 /// The catalog pg_opfamily defines operator families. Each operator family is a collection of operators and associated support routines that implement the semantics specified for a particular index access method. Furthermore, the operators in a family are all “compatible”, in a way that is specified by the access method. The operator family concept allows cross-data-type operators to be used with indexes and to be reasoned about using knowledge of access method semantics.
825 catalog (pg_opfamily) {
826 /// Row identifier.
827 (oid, Oid, get_struct)
828 /// Index access method operator family is for.
829 (opfmethod, Oid, get_struct)
830 /// Name of this operator family.
831 (opfname, &CStr, get_struct)
832 /// Namespace of this operator family.
833 (opfnamespace, Oid, get_struct)
834 /// Owner of the operator family.
835 (opfowner, Oid, get_struct)
836 }
837}
838
839define_catalog! {
840 /// The catalog pg_proc stores information about functions, procedures, aggregate functions, and window functions (collectively also known as routines).
841 catalog (pg_proc) {
842 /// Row identifier.
843 (oid, Oid, get_struct)
844 /// Name of the function.
845 (proname, &CStr, get_struct)
846 /// The OID of the namespace that contains this function.
847 (pronamespace, Oid, get_struct)
848 /// Owner of the function.
849 (proowner, Oid, get_struct)
850 /// Implementation language or call interface of this function.
851 (prolang, Oid, get_struct)
852 /// Estimated execution cost (in units of cpu_operator_cost); if proretset, this is cost per row returned.
853 (procost, f32, get_struct)
854 /// Estimated number of result rows (zero if not proretset).
855 (prorows, f32, get_struct)
856 /// Data type of the variadic array parameter's elements, or zero if the function does not have a variadic parameter.
857 (provariadic, Oid, get_struct)
858 /// Planner support function for this function, or zero if none.
859 (prosupport, Regproc, get_struct)
860 (prokind, PgProcProkind, character {
861 /// f for a normal function
862 (Function, b'f')
863 /// p for a procedure
864 (Procedure, b'p')
865 /// a for an aggregate function
866 (Aggregate, b'a')
867 /// w for a window function
868 (Window, b'w')
869 }, get_struct)
870 /// Function is a security definer (i.e., a “setuid” function).
871 (prosecdef, bool, get_struct)
872 /// The function has no side effects. No information about the arguments is conveyed except via the return value. Any function that might throw an error depending on the values of its arguments is not leak-proof.
873 (proleakproof, bool, get_struct)
874 /// Function returns null if any call argument is null. In that case the function won't actually be called at all. Functions that are not “strict” must be prepared to handle null inputs.
875 (proisstrict, bool, get_struct)
876 /// Function returns a set (i.e., multiple values of the specified data type).
877 (proretset, bool, get_struct)
878 /// provolatile tells whether the function's result depends only on its input arguments, or is affected by outside factors.
879 (provolatile, PgProcProvolatile, character {
880 /// i for “immutable” functions, which always deliver the same result for the same inputs
881 (Immutable, b'i')
882 /// s for “stable” functions, whose results (for fixed inputs) do not change within a scan
883 (Stable, b's')
884 /// v for “volatile” functions, whose results might change at any time (Use v also for functions with side-effects, so that calls to them cannot get optimized away.)
885 (Volatile, b'v')
886 }, get_struct)
887 /// proparallel tells whether the function can be safely run in parallel mode.
888 (proparallel, PgProcProparallel, character {
889 /// s for functions which are safe to run in parallel mode without restriction
890 (Safe, b's')
891 /// r for functions which can be run in parallel mode, but their execution is restricted to the parallel group leader; parallel worker processes cannot invoke these functions
892 (Restricted, b'r')
893 /// u for functions which are unsafe in parallel mode; the presence of such a function forces a serial execution plan
894 (Unsafe, b'u')
895 }, get_struct)
896 /// Number of input arguments.
897 (pronargs, i16, get_struct)
898 /// Number of arguments that have defaults.
899 (pronargdefaults, i16, get_struct)
900 /// Data type of the return value.
901 (prorettype, Oid, get_struct)
902 /// An array of the data types of the function arguments. This includes only input arguments (including INOUT and VARIADIC arguments), and thus represents the call signature of the function.
903 (proargtypes, &[Oid], get_struct)
904 /// An array of the data types of the function arguments. This includes all arguments (including OUT and INOUT arguments); however, if all the arguments are IN arguments, this field will be null. Note that subscripting is 1-based, whereas for historical reasons proargtypes is subscripted from 0.
905 (proallargtypes, Array<'_, Oid>, get_attr)
906 /// An array of the modes of the function arguments. If all the arguments are IN arguments, this field will be null. Note that subscripts correspond to positions of proallargtypes not proargtypes.
907 (proargmodes, Array<'_, PgProcProargmodes>, character {
908 /// i for IN arguments
909 (In, b'i')
910 /// o for OUT arguments
911 (Out, b'o')
912 /// b for INOUT arguments
913 (Inout, b'b')
914 /// v for VARIADIC arguments
915 (Variadic, b'v')
916 /// t for TABLE arguments
917 (Table, b't')
918 }, get_attr)
919 /// An array of the names of the function arguments. Arguments without a name are set to empty strings in the array. If none of the arguments have a name, this field will be null. Note that subscripts correspond to positions of proallargtypes not proargtypes.
920 (proargnames, Array<'_, String>, get_attr)
921 // (proargdefaults, pg_node_tree, get_attr)
922 /// An array of the argument/result data type(s) for which to apply transforms (from the function's TRANSFORM clause). Null if none.
923 (protrftypes, Array<'_, Oid>, get_attr)
924 /// This tells the function handler how to invoke the function. It might be the actual source code of the function for interpreted languages, a link symbol, a file name, or just about anything else, depending on the implementation language/call convention.
925 (prosrc, &str, get_attr_notnull)
926 /// Additional information about how to invoke the function. Again, the interpretation is language-specific.
927 (probin, &str, get_attr)
928 // (prosqlbody, pg_node_tree, get_attr)
929 /// Function's local settings for run-time configuration variables.
930 (proconfig, Array<'_, String>, get_attr)
931 // (proacl, aclitem[], get_attr)
932 }
933}
934
935define_catalog! {
936 /// The catalog pg_type stores information about data types. Base types and enum types (scalar types) are created with CREATE TYPE, and domains with CREATE DOMAIN. A composite type is automatically created for each table in the database, to represent the row structure of the table. It is also possible to create composite types with CREATE TYPE AS.
937 catalog (pg_type) {
938 /// Row identifier.
939 (oid, Oid, get_struct)
940 /// Data type name.
941 (typname, &CStr, get_struct)
942 /// The OID of the namespace that contains this type.
943 (typnamespace, Oid, get_struct)
944 /// Owner of the type.
945 (typowner, Oid, get_struct)
946 /// For a fixed-size type, typlen is the number of bytes in the internal representation of the type. But for a variable-length type, typlen is negative. -1 indicates a “varlena” type (one that has a length word), -2 indicates a null-terminated C string.
947 (typlen, i16, get_struct)
948 /// typbyval determines whether internal routines pass a value of this type by value or by reference. typbyval had better be false if typlen is not 1, 2, or 4 (or 8 on machines where Datum is 8 bytes). Variable-length types are always passed by reference. Note that typbyval can be false even if the length would allow pass-by-value.
949 (typbyval, bool, get_struct)
950 /// See also typrelid and typbasetype.
951 (typtype, PgTypeTyptype, character {
952 /// b for a base type
953 (Base, b'b')
954 /// c for a composite type (e.g., a table's row type)
955 (Composite, b'c')
956 /// d for a domain
957 (Domain, b'd')
958 /// e for an enum type
959 (Enum, b'e')
960 /// m for a multirange type
961 (Multirange, b'm')
962 /// p for a pseudo-type
963 (Pseudo, b'p')
964 /// r for a range type
965 (Range, b'r')
966 }, get_struct)
967 /// typcategory is an arbitrary classification of data types that is used by the parser to determine which implicit casts should be “preferred”.
968 (typcategory, PgTypeTypcategory, character {
969 /// Array types
970 (Array, b'A')
971 /// Boolean types
972 (Boolean, b'B')
973 /// Composite types
974 (Composite, b'C')
975 /// Date/time types
976 (DateTime, b'D')
977 /// Enum types
978 (Enum, b'E')
979 /// Geometric types
980 (Geometric, b'G')
981 /// Network address types
982 (Network, b'I')
983 /// Numeric types
984 (Numeric, b'N')
985 /// Pseudo-types
986 (PseudoType, b'P')
987 /// Range types
988 (Range, b'R')
989 /// String types
990 (String, b'S')
991 /// Timespan types
992 (TimeSpan, b'T')
993 /// User-defined types
994 (User, b'U')
995 /// Bit-string types
996 (BitString, b'V')
997 /// unknown type
998 (Unknown, b'X')
999 /// Internal-use types
1000 (Internal, b'Z')
1001 }, get_struct)
1002 /// True if the type is a preferred cast target within its typcategory.
1003 (typispreferred, bool, get_struct)
1004 /// True if the type is defined, false if this is a placeholder entry for a not-yet-defined type. When typisdefined is false, nothing except the type name, namespace, and OID can be relied on.
1005 (typisdefined, bool, get_struct)
1006 /// Character that separates two values of this type when parsing array input. Note that the delimiter is associated with the array element data type, not the array data type.
1007 (typdelim, c_char, get_struct)
1008 /// If this is a composite type (see typtype), then this column points to the pg_class entry that defines the corresponding table. (For a free-standing composite type, the pg_class entry doesn't really represent a table, but it is needed anyway for the type's pg_attribute entries to link to.) Zero for non-composite types.
1009 (typrelid, Oid, get_struct)
1010 #[cfg(any(feature = "pg14", feature = "pg15", feature = "pg16", feature = "pg17", feature = "pg18", feature = "pg19"))]
1011 /// Subscripting handler function's OID, or zero if this type doesn't support subscripting. Types that are “true” array types have typsubscript = array_subscript_handler, but other types may have other handler functions to implement specialized subscripting behavior.
1012 (typsubscript, Regproc, get_struct)
1013 /// If typelem is not zero then it identifies another row in pg_type, defining the type yielded by subscripting. This should be zero if typsubscript is zero. However, it can be zero when typsubscript isn't zero, if the handler doesn't need typelem to determine the subscripting result type. Note that a typelem dependency is considered to imply physical containment of the element type in this type; so DDL changes on the element type might be restricted by the presence of this type.
1014 (typelem, Oid, get_struct)
1015 /// If typarray is not zero then it identifies another row in pg_type, which is the “true” array type having this type as element.
1016 (typarray, Oid, get_struct)
1017 /// Input conversion function (text format).
1018 (typinput, Regproc, get_struct)
1019 /// Output conversion function (text format).
1020 (typoutput, Regproc, get_struct)
1021 /// Input conversion function (binary format), or zero if none.
1022 (typreceive, Regproc, get_struct)
1023 /// Output conversion function (binary format), or zero if none.
1024 (typsend, Regproc, get_struct)
1025 /// Type modifier input function, or zero if type does not support modifiers.
1026 (typmodin, Regproc, get_struct)
1027 /// Type modifier output function, or zero to use the standard format.
1028 (typmodout, Regproc, get_struct)
1029 /// Custom ANALYZE function, or zero to use the standard function.
1030 (typanalyze, Regproc, get_struct)
1031 /// typalign is the alignment required when storing a value of this type. It applies to storage on disk as well as most representations of the value inside PostgreSQL. When multiple values are stored consecutively, such as in the representation of a complete row on disk, padding is inserted before a datum of this type so that it begins on the specified boundary. The alignment reference is the beginning of the first datum in the sequence.
1032 (typalign, PgTypeTypalign, character {
1033 /// c = char alignment, i.e., no alignment needed.
1034 (Char, b'c')
1035 /// s = short alignment (2 bytes on most machines).
1036 (Short, b's')
1037 /// i = int alignment (4 bytes on most machines).
1038 (Int, b'i')
1039 /// d = double alignment (8 bytes on many machines, but by no means all).
1040 (Double, b'd')
1041 }, get_struct)
1042 /// typstorage tells for varlena types (those with typlen = -1) if the type is prepared for toasting and what the default strategy for attributes of this type should be.
1043 /// x is the usual choice for toast-able types. Note that m values can also be moved out to secondary storage, but only as a last resort (e and x values are moved first).
1044 (typstorage, PgTypeTypstorage, character {
1045 /// p (plain): Values must always be stored plain (non-varlena types always use this value).
1046 (Plain, b'p')
1047 /// e (external): Values can be stored in a secondary “TOAST” relation (if relation has one, see pg_class.reltoastrelid).
1048 (External, b'e')
1049 /// x (extended): Values can be compressed and/or moved to a secondary relation.
1050 (Extended, b'x')
1051 /// m (main): Values can be compressed and stored inline.
1052 (Main, b'm')
1053 }, get_struct)
1054 /// typnotnull represents a not-null constraint on a type. Used for domains only.
1055 (typnotnull, bool, get_struct)
1056 /// If this is a domain (see typtype), then typbasetype identifies the type that this one is based on. Zero if this type is not a domain.
1057 (typbasetype, Oid, get_struct)
1058 /// Domains use typtypmod to record the typmod to be applied to their base type (-1 if base type does not use a typmod). -1 if this type is not a domain.
1059 (typtypmod, i32, get_struct)
1060 /// typndims is the number of array dimensions for a domain over an array (that is, typbasetype is an array type). Zero for types other than domains over array types.
1061 (typndims, i32, get_struct)
1062 /// typcollation specifies the collation of the type. If the type does not support collations, this will be zero. A base type that supports collations will have a nonzero value here, typically DEFAULT_COLLATION_OID. A domain over a collatable type can have a collation OID different from its base type's, if one was specified for the domain.
1063 (typcollation, Oid, get_struct)
1064 // (typdefaultbin, pg_node_tree, get_attr)
1065 /// typdefault is null if the type has no associated default value. If typdefaultbin is not null, typdefault must contain a human-readable version of the default expression represented by typdefaultbin. If typdefaultbin is null and typdefault is not, then typdefault is the external representation of the type's default value, which can be fed to the type's input converter to produce a constant.
1066 (typdefault, String, get_attr)
1067 // (typacl, aclitem[], get_attr)
1068 }
1069}
1070
1071define_cache! {
1072 cache (amname, pg_am) {
1073 (amname, &CStr)
1074 }
1075}
1076
1077define_cache! {
1078 cache (amoid, pg_am) {
1079 (oid, Oid)
1080 }
1081}
1082
1083define_cache! {
1084 cache (amopopid, pg_amop) {
1085 (amopopr, Oid)
1086 (amoppurpose, PgAmopAmoppurpose)
1087 (amopfamily, Oid)
1088 }
1089}
1090
1091define_cache! {
1092 cache (amopstrategy, pg_amop) {
1093 (amopfamily, Oid)
1094 (amoplefttype, Oid)
1095 (amoprighttype, Oid)
1096 (amopstrategy, i16)
1097 }
1098}
1099
1100define_cache! {
1101 cache (amprocnum, pg_amproc) {
1102 (amprocfamily, Oid)
1103 (amproclefttype, Oid)
1104 (amprocrighttype, Oid)
1105 (amprocnum, i16)
1106 }
1107}
1108
1109define_cache! {
1110 cache (claamnamensp, pg_opclass) {
1111 (opcmethod, Oid)
1112 (opcname, &CStr)
1113 (opcnamespace, Oid)
1114 }
1115}
1116
1117define_cache! {
1118 cache (claoid, pg_opclass) {
1119 (oid, Oid)
1120 }
1121}
1122
1123define_cache! {
1124 cache (enumoid, pg_enum) {
1125 (oid, Oid)
1126 }
1127}
1128
1129define_cache! {
1130 cache (enumtypoidname, pg_enum) {
1131 (enumtypid, Oid)
1132 (enumlabel, &CStr)
1133 }
1134}
1135
1136define_cache! {
1137 cache (indexrelid, pg_index) {
1138 (indexrelid, Oid)
1139 }
1140}
1141
1142define_cache! {
1143 cache (namespacename, pg_namespace) {
1144 (nspname, &CStr)
1145 }
1146}
1147
1148define_cache! {
1149 cache (namespaceoid, pg_namespace) {
1150 (oid, Oid)
1151 }
1152}
1153
1154define_cache! {
1155 cache (opernamensp, pg_operator) {
1156 (oprname, &CStr)
1157 (oprleft, Oid)
1158 (oprright, Oid)
1159 (oprnamespace, Oid)
1160 }
1161}
1162
1163define_cache! {
1164 cache (operoid, pg_operator) {
1165 (oid, Oid)
1166 }
1167}
1168
1169define_cache! {
1170 cache (opfamilyamnamensp, pg_opfamily) {
1171 (opfmethod, Oid)
1172 (opfname, &CStr)
1173 (opfnamespace, Oid)
1174 }
1175}
1176
1177define_cache! {
1178 cache (opfamilyoid, pg_opfamily) {
1179 (oid, Oid)
1180 }
1181}
1182
1183define_cache! {
1184 cache (procnameargsnsp, pg_proc) {
1185 (proname, &CStr)
1186 (proargtypes, &[Oid])
1187 (pronamespace, Oid)
1188 }
1189}
1190
1191define_cache! {
1192 cache (procoid, pg_proc) {
1193 (oid, Oid)
1194 }
1195}
1196
1197define_cache! {
1198 cache (relnamensp, pg_class) {
1199 (relname, &CStr)
1200 (relnamespace, Oid)
1201 }
1202}
1203
1204define_cache! {
1205 cache (reloid, pg_class) {
1206 (oid, Oid)
1207 }
1208}
1209
1210define_cache! {
1211 cache (typenamensp, pg_type) {
1212 (typname, &CStr)
1213 (typnamespace, Oid)
1214 }
1215}
1216
1217define_cache! {
1218 cache (typeoid, pg_type) {
1219 (oid, Oid)
1220 }
1221}