public inbox for [email protected]  
help / color / mirror / Atom feed
From: plsqlvids01 plsqlvids01 <[email protected]>
To: [email protected]
Subject: use of postgres reg* datatypes in user tables?
Date: Mon, 19 Aug 2024 02:08:48 -0400
Message-ID: <CAFsfSrs+_7Aie27FPB+HnH0vEeT3h=5ZJj7k=OWDYTGksmYPiw@mail.gmail.com> (raw)

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'?


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: use of postgres reg* datatypes in user tables?
  In-Reply-To: <CAFsfSrs+_7Aie27FPB+HnH0vEeT3h=5ZJj7k=OWDYTGksmYPiw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox