use of postgres reg* datatypes in user tables? - Mailing list pgsql-general

From plsqlvids01 plsqlvids01
Subject use of postgres reg* datatypes in user tables?
Date
Msg-id CAFsfSrs+_7Aie27FPB+HnH0vEeT3h=5ZJj7k=OWDYTGksmYPiw@mail.gmail.com
Whole thread Raw
Responses Re: use of postgres reg* datatypes in user tables?
Re: use of postgres reg* datatypes in user tables?
List pgsql-general
What is the use of postgres regclass datatype in user tables? When would one want to use them when regular data types are available? If any tables have these data types, since pg_upgrade would fail, what data types should those be converted to?

```
postgres=> select version();
                                                 version                                                  
----------------------------------------------------------------------------------------------------------
 PostgreSQL 14.11 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit
(1 row)

\dT pg_catalog.reg*
                        List of data types
   Schema   │     Name      │             Description              
════════════╪═══════════════╪══════════════════════════════════════
 pg_catalog │ regclass      │ registered class
 pg_catalog │ regcollation  │ registered collation
 pg_catalog │ regconfig     │ registered text search configuration
 pg_catalog │ regdictionary │ registered text search dictionary
 pg_catalog │ regnamespace  │ registered namespace
 pg_catalog │ regoper       │ registered operator
 pg_catalog │ regoperator   │ registered operator (with args)
 pg_catalog │ regproc       │ registered procedure
 pg_catalog │ regprocedure  │ registered procedure (with args)
 pg_catalog │ regrole       │ registered role
 pg_catalog │ regtype       │ registered type
(11 rows)

postgres=> create table t1 (c1 int, c2 regclass);
CREATE TABLE
postgres=> \d t1;
               Table "public.t1"
 Column |   Type   | Collation | Nullable | Default
--------+----------+-----------+----------+---------
 c1     | integer  |           |          |
 c2     | regclass |           |          |

postgres=> insert into t1 values(1,1);
INSERT 0 1
postgres=> insert into t1 values(2,'2');
INSERT 0 1
postgres=> insert into t1 values(3,'3'::int);
INSERT 0 1
postgres=> insert into t1 values(4,'4'::text);
ERROR:  relation "4" does not exist
postgres=> select * from t1;
 c1 | c2
----+----
  1 | 1
  2 | 2
  3 | 3
(3 rows)
```
What kind of data does these data types store - numbers or text? In above example am able to insert it as number as well as character '2'?

pgsql-general by date:

Previous
From: Greg Sabino Mullane
Date:
Subject: Re: Column type modification in big tables
Next
From: sud
Date:
Subject: Insert query performance