From: | Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> |
Subject: | Re: dealing with extension dependencies that aren't quite 'e' |
Date: | 2016-03-24 17:18:51 |
Message-ID: | 20160324171851.GA12244@toroid.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At 2016-03-24 12:31:16 -0300, alvherre(at)2ndquadrant(dot)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
Attachment | Content-Type | Size |
---|---|---|
extdepend-wip-20160324.diff | text/x-diff | 13.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Aleksey Demakov | 2016-03-24 17:20:22 | Re: Rationalizing code-sharing among src/bin/ directories |
Previous Message | Robert Haas | 2016-03-24 17:17:06 | Re: Combining Aggregates |