Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement

Поиск
Список
Период
Сортировка
От Chao Li
Тема Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement
Дата
Msg-id 581DFE68-6E53-4B4B-8B4C-02AB06731EF8@gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement  (Philip Alger <paalger0@gmail.com>)
Ответы Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement
Список pgsql-hackers

> On Nov 1, 2025, at 06:29, Philip Alger <paalger0@gmail.com> wrote:
>
>
> <v2-0001-Add-pg_get_type_ddl-function.patch>

1
```
+    /*
+     * Look up the type tuple to allow shell types.
+     */
+    typeTup = LookupTypeName(NULL, typeStruct, NULL, false);
+    if (typeTup == NULL)
+        ereport(ERROR,
+                (errcode(ERRCODE_UNDEFINED_OBJECT),
+                 errmsg("type \"%s\" does not exist",
+                        TypeNameToString(typeStruct))));
```

Here when you call LookupTypeName(), you give the last parameter “missing_ok” a value of “false”, so that it would
“ereport”inside LookupTypeName(), so your manual check of “if (typeTup == NULL)” will never be satisfied. 

2
```
+{ oid => '8414', descr => 'get CREATE statement for type',
+  proname => 'pg_get_type_ddl', prorettype => 'text', proisstrict => 't',
+  proargtypes => 'text', proargnames => '{typname}',
+  prosrc => 'pg_get_type_ddl' },
```
Here you set  proisstrict => ’t’. With strict mode, the function will not be executed if any of input arguments are
NULL.

So add this test seems meaningless, because the function is not executed at all.
```
+SELECT pg_get_type_ddl(NULL);
+ pg_get_type_ddl
+-----------------
+
+(1 row)
```

3. As discussed in other get_xxx_ddl() patches, does this function needs a pretty flag? I think other patches have
that.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







В списке pgsql-hackers по дате отправления: