v2-0002-minor-refactor-based-on-v1-0001.patch

application/x-patch

Filename: v2-0002-minor-refactor-based-on-v1-0001.patch
Type: application/x-patch
Part: 1
Message: Re: Add pg_basetype() function to obtain a DOMAIN base type

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v2-0002
Subject: minor refactor based on v1-0001
File+
doc/src/sgml/func.sgml 25 25
src/backend/utils/adt/misc.c 1 1
src/include/catalog/pg_proc.dat 1 1
From 8d28abd4f69064317b8733c74de3284c3fbc85ad Mon Sep 17 00:00:00 2001
From: pgaddict <jian.universality@gmail.com>
Date: Mon, 1 Jan 2024 13:14:12 +0800
Subject: [PATCH v2 2/2] minor refactor based on v1-0001

doc: place function pg_basetype under
"System Catalog Information Function" section.

Other miscellaneous changes,
make pg_basetype functions looks like similar to pg_typeof.
---
 doc/src/sgml/func.sgml          | 50 ++++++++++++++++-----------------
 src/backend/utils/adt/misc.c    |  2 +-
 src/include/catalog/pg_proc.dat |  2 +-
 3 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 7b14c87c..8f66de3b 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -24698,31 +24698,6 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
        </para></entry>
       </row>
 
-      <row>
-       <entry role="func_table_entry"><para role="func_signature">
-        <indexterm>
-         <primary>pg_basetype</primary>
-        </indexterm>
-        <function>pg_basetype</function> ( <parameter>type</parameter> <type>oid</type> )
-        <returnvalue>regtype</returnvalue>
-       </para>
-       <para>
-       Returns the OID of the base type of a domain or if the argument is a basetype it returns the same type.
-       If there's a chain of domain dependencies, it will recurse until finding the base type.
-       </para>
-       <para>
-        For example:
-<programlisting>
-CREATE DOMAIN mytext as text;
-
-SELECT pg_basetype('mytext'::regtype);
- pg_typeof
------------
- text
-</programlisting>
-       </para></entry>
-      </row>
-
       <row>
        <entry role="func_table_entry"><para role="func_signature">
         <indexterm>
@@ -25021,6 +24996,31 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
        </para></entry>
       </row>
 
+      <row>
+       <entry role="func_table_entry"><para role="func_signature">
+        <indexterm>
+         <primary>pg_basetype</primary>
+        </indexterm>
+        <function>pg_basetype</function> ( <type>"any"</type> )
+        <returnvalue>regtype</returnvalue>
+       </para>
+       <para>
+       Returns the OID of the base type of a domain or if the argument is a basetype it returns the same type.
+       If there's a chain of domain dependencies, it will recurse until finding the base type.
+       </para>
+       <para>
+        For example:
+<programlisting>
+CREATE DOMAIN mytext as text;
+
+SELECT pg_basetype('mytext'::regtype);
+ pg_basetype
+-----------
+ text
+</programlisting>
+       </para></entry>
+      </row>
+
       <row>
        <entry id="pg-char-to-encoding" role="func_table_entry"><para role="func_signature">
         <indexterm>
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index c0c3c9e9..692621c2 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -43,9 +43,9 @@
 #include "tcop/tcopprot.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
-#include "utils/syscache.h"
 #include "utils/lsyscache.h"
 #include "utils/ruleutils.h"
+#include "utils/syscache.h"
 #include "utils/timestamp.h"
 
 
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index f84f106b..db037455 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3879,7 +3879,7 @@
   prorettype => 'regtype', proargtypes => 'any', prosrc => 'pg_typeof' },
 { oid => '6312', descr => 'get the base type of a domain',
   proname => 'pg_basetype', proisstrict => 'f', provolatile => 's',
-  prorettype => 'regtype', proargtypes => 'oid', prosrc => 'pg_basetype' },
+  prorettype => 'regtype', proargtypes => 'any', prosrc => 'pg_basetype' },
 { oid => '3162',
   descr => 'collation of the argument; implementation of the COLLATION FOR expression',
   proname => 'pg_collation_for', proisstrict => 'f', provolatile => 's',
-- 
2.34.1