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

Поиск
Список
Период
Сортировка
От Philip Alger
Тема Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement
Дата
Msg-id CAPXBC8LDGT6Ptf4GJh57My439BfC2gNY8ATn_fszfDUs7xTApQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement  (Chao Li <li.evan.chao@gmail.com>)
Список pgsql-hackers
Hi Chao, 

Appreciate you pulling it apart: 

 
1
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.

Yeah, I changed that to `true`, so it should handle correctly now - v3. But not sure how you got "it would “ereport” inside LookupTypeName()". I don't see where ereport would happen inside `LookupTypeNameExtended`. It seems like it would hit here and return NULL:

if (!OidIsValid(typoid))
{
     if (typmod_p)
     *typmod_p = -1;
     return NULL;
}
 
2
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)

I added that test to make sure it provides no output. 

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

I see three functions that a couple people posted that use it; however, for pg_get_policy_ddl is the only one using it to format the code. I am not sure there is consensus on how SQL should be formatted. 

--
Best, 
Phil Alger
Вложения

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