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 | 20160324171851.GA12244@toroid.org обсуждение исходный текст | 
| Ответ на | Re: dealing with extension dependencies that aren't quite 'e' (Alvaro Herrera <alvherre@2ndquadrant.com>) | 
| Ответы | Re: dealing with extension dependencies that aren't quite
 'e' | 
| Список | pgsql-hackers | 
At 2016-03-24 12:31:16 -0300, alvherre@2ndquadrant.com wrote:
>
> In other words I think the conclusion here is that we must use
> qualified_name in the new production rather than switching the old
> production to any_name.
Makes sense.
> 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:
+ObjectAddress
+ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt)
+{
+    ObjectAddress address;
+    ObjectAddress extAddr;
+    Relation    rel = NULL;
+
+    /*
+     * If the parser handed us a RangeVar, we add the relation's name to
+     * stmt->objname so that we can pass it to get_object_address().
+     */
+    if (stmt->relation)
+    {
+        stmt->objname = lcons(makeString(stmt->relation->relname), stmt->objname);
+        if (stmt->relation->schemaname)
+            stmt->objname = lcons(makeString(stmt->relation->schemaname), stmt->objname);
+        if (stmt->relation->catalogname)
+            stmt->objname = lcons(makeString(stmt->relation->catalogname), stmt->objname);
+    }
+
+    address = get_object_address(stmt->objectType, 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;
+}
(This works fine for both functions and triggers, I tested it.)
Complete patch attached for reference.
I'll post the get_object_address_rv() variant tomorrow, but comments are
welcome in the meantime.
-- Abhijit
		
	Вложения
В списке pgsql-hackers по дате отправления: