jrgemignani commented on code in PR #2438:
URL: https://github.com/apache/age/pull/2438#discussion_r3444865507
##########
src/backend/catalog/ag_catalog.c:
##########
@@ -183,7 +279,7 @@ static bool is_age_drop(PlannedStmt *pstmt)
String *val = (String *)obj;
char *str = val->sval;
- if (!pg_strcasecmp(str, "age"))
+ if (strcmp(str, "age") == 0)
return true;
Review Comment:
Needs to be wrapped in {}
##########
src/backend/age.c:
##########
@@ -56,6 +58,9 @@ void _PG_init(void);
void _PG_init(void)
{
+ if (IsBinaryUpgrade)
+ return;
Review Comment:
All blocks are wrapped with {} even if it is just one line of code.
##########
src/backend/catalog/ag_catalog.c:
##########
@@ -205,15 +301,11 @@ static void object_access(ObjectAccessType access, Oid
class_id, Oid object_id,
if (prev_object_access_hook)
prev_object_access_hook(access, class_id, object_id, sub_id, arg);
- /* We are interested in DROP SCHEMA and DROP TABLE commands. */
- if (access != OAT_DROP)
+ if (!is_age_extension_exists())
return;
- /*
- * Age might be installed into shared_preload_libraries before extension is
- * created. In this case we must bail out from this hook.
- */
- if (!OidIsValid(get_namespace_oid("ag_catalog", true)))
+ /* We are interested in DROP SCHEMA and DROP TABLE commands. */
+ if (access != OAT_DROP)
return;
Review Comment:
Needs to be wrapped in {}
##########
src/backend/optimizer/cypher_paths.c:
##########
@@ -66,6 +67,9 @@ static void set_rel_pathlist(PlannerInfo *root, RelOptInfo
*rel, Index rti,
if (prev_set_rel_pathlist_hook)
prev_set_rel_pathlist_hook(root, rel, rti, rte);
+ if (!is_age_extension_exists())
+ return;
Review Comment:
Needs to be wrapped in {}
##########
src/backend/parser/cypher_analyze.c:
##########
@@ -86,6 +87,9 @@ static void post_parse_analyze(ParseState *pstate, Query
*query, JumbleState *js
prev_post_parse_analyze_hook(pstate, query, jstate);
}
+ if (!is_age_extension_exists())
+ return;
Review Comment:
Needs to be wrapped in {}
##########
src/backend/catalog/ag_catalog.c:
##########
@@ -45,8 +51,44 @@ void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char
*queryString, bool re
QueryEnvironment *queryEnv, DestReceiver *dest,
QueryCompletion *qc);
-static bool is_age_drop(PlannedStmt *pstmt);
-static void drop_age_extension(DropStmt *stmt);
+static bool is_age_drop(DropStmt *drop_stmt);
+
+static void
+invalidate_extension_cache_callback(Datum argument, Oid relationId)
+{
+ if (!OidIsValid(relationId) || relationId == ExtensionRelationId)
+ extension_cache_is_valid = false;
Review Comment:
Needs to be wrapped in {}
##########
src/backend/catalog/ag_catalog.c:
##########
@@ -141,39 +230,46 @@ void ag_ProcessUtility_hook(PlannedStmt *pstmt, const
char *queryString,
params, queryEnv, dest, qc);
}
}
-}
-
-static void drop_age_extension(DropStmt *stmt)
-{
- /* Remove all graphs */
- drop_graphs(get_graphnames());
+ PG_CATCH();
+ {
+ if (dropping_age)
+ {
+ /*
+ * We have to restore the disabled object_access_hook if
+ * DROP EXTENSION age failed.
+ */
+ object_access_hook_init();
+ }
+ PG_RE_THROW();
+ }
+ PG_END_TRY();
- /* Remove the object access hook */
- object_access_hook_fini();
+ if (dropping_age)
+ {
+ /* reset global variables for OIDs */
+ clear_global_Oids_AGTYPE();
+ clear_global_Oids_GRAPHID();
+ clear_global_Oids_VERTEX_EDGE();
- /*
- * Run Postgres' logic to perform the remaining work to drop the
- * extension.
- */
- RemoveObjects(stmt);
+ /* Restore the object access hook */
+ object_access_hook_init();
+ }
- /* reset global variables for OIDs */
- clear_global_Oids_AGTYPE();
- clear_global_Oids_GRAPHID();
- clear_global_Oids_VERTEX_EDGE();
+ if (creating_age || dropping_age)
+ {
+ /* Notify all backends that pg_extension was modified. */
+ CacheInvalidateRelcacheByRelid(ExtensionRelationId);
+ }
}
/* Check to see if the Utility Command is to drop the AGE Extension. */
-static bool is_age_drop(PlannedStmt *pstmt)
+static bool is_age_drop(DropStmt *drop_stmt)
{
ListCell *lc;
- DropStmt *drop_stmt;
- if (!IsA(pstmt->utilityStmt, DropStmt))
+ if (!is_age_extension_exists())
return false;
Review Comment:
Needs to be wrapped in {}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]