Re: dealing with extension dependencies that aren't quite 'e'

Поиск
Список
Период
Сортировка
От Abhijit Menon-Sen
Тема Re: dealing with extension dependencies that aren't quite 'e'
Дата
Msg-id 20160325175720.GA31814@toroid.org
обсуждение исходный текст
Ответ на Re: dealing with extension dependencies that aren't quite 'e'  (Abhijit Menon-Sen <ams@2ndQuadrant.com>)
Ответы Re: dealing with extension dependencies that aren't quite 'e'  (David Steele <david@pgmasters.net>)
Список pgsql-hackers
At 2016-03-24 22:48:51 +0530, ams@2ndQuadrant.com wrote:
>
> > I think I would like to see code implement both alternatives to see
> > which one is least ugly.  Maybe a third idea will manifest itself
> > upon seeing those.
>
> Here's the first one. ExecAlterObjectDependsStmt() looks like this:

Here's the second one, which is only slightly different from the first.
ExecAlterObjectDependsStmt() now looks like this:

+ObjectAddress
+ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt)
+{
+    ObjectAddress address;
+    ObjectAddress extAddr;
+    Relation    rel = NULL;
+
+    address = get_object_address_rv(stmt->objectType, stmt->relation, stmt->objname,
+                                    stmt->objargs, &rel, AccessExclusiveLock, false);
+
+    if (rel)
+        heap_close(rel, NoLock);
+
+    extAddr = get_object_address(OBJECT_EXTENSION, stmt->extname, NULL,
+                                 &rel, AccessExclusiveLock, false);
+
+    recordDependencyOn(&address, &extAddr, DEPENDENCY_AUTO_EXTENSION);
+
+    return address;
+}

And the new get_object_address_rv() looks like this:

+ObjectAddress
+get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
+                      List *objargs, Relation *relp, LOCKMODE lockmode,
+                      bool missing_ok)
+{
+    if (rel)
+    {
+        objname = lcons(makeString(rel->relname), objname);
+        if (rel->schemaname)
+            objname = lcons(makeString(rel->schemaname), objname);
+        if (rel->catalogname)
+            objname = lcons(makeString(rel->catalogname), objname);
+    }
+
+    return get_object_address(objtype, objname, objargs,
+                              relp, lockmode, missing_ok);
+}

Complete patch attached for reference, as before. (I know I haven't
documented the function. I will go through the code to see if there are
any other potential callers, but I wanted to share what I had already.)

-- Abhijit

Вложения

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

Предыдущее
От: Dmitry Dolgov
Дата:
Сообщение: Re: [PATH] Jsonb, insert a new value into an array at arbitrary position
Следующее
От: Vladimir Borodin
Дата:
Сообщение: Re: Improving replay of XLOG_BTREE_VACUUM records