projects
/
online_analyze.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3ce4df2
)
Fix wrong usage of RegisterXactCallback()
author
Teodor Sigaev
<teodor@sigaev.ru>
Wed, 14 Jun 2017 12:22:11 +0000
(15:22 +0300)
committer
Teodor Sigaev
<teodor@sigaev.ru>
Wed, 14 Jun 2017 12:22:11 +0000
(15:22 +0300)
online_analyze.c
patch
|
blob
|
history
diff --git
a/online_analyze.c
b/online_analyze.c
index
9c7fe20
..
53ffd20
100644
(file)
--- a/
online_analyze.c
+++ b/
online_analyze.c
@@
-649,8
+649,7
@@
isFastTruncateCall(QueryDesc *queryDesc)
queryDesc->operation == CMD_SELECT &&
queryDesc->plannedstmt->planTree &&
queryDesc->plannedstmt->planTree->targetlist &&
queryDesc->operation == CMD_SELECT &&
queryDesc->plannedstmt->planTree &&
queryDesc->plannedstmt->planTree->targetlist &&
- list_length(queryDesc->plannedstmt->planTree->targetlist) == 1 &&
- IsA(linitial(queryDesc->plannedstmt->planTree->targetlist), TargetEntry)
+ list_length(queryDesc->plannedstmt->planTree->targetlist) == 1
))
return NULL;
))
return NULL;
@@
-667,8
+666,7
@@
isFastTruncateCall(QueryDesc *queryDesc)
fe->funcretset == false &&
fe->funcresulttype == VOIDOID &&
fe->funcvariadic == false &&
fe->funcretset == false &&
fe->funcresulttype == VOIDOID &&
fe->funcvariadic == false &&
- list_length(fe->args) == 1 &&
- IsA(linitial(fe->args), Const)
+ list_length(fe->args) == 1
))
return NULL;
))
return NULL;
@@
-685,7
+683,6
@@
isFastTruncateCall(QueryDesc *queryDesc)
}
}
-
extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
void
onlineAnalyzeHooker(QueryDesc *queryDesc)
extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
void
onlineAnalyzeHooker(QueryDesc *queryDesc)
@@
-753,14
+750,25
@@
onlineAnalyzeHooker(QueryDesc *queryDesc)
standard_ExecutorEnd(queryDesc);
}
standard_ExecutorEnd(queryDesc);
}
+static List *toremove = NIL;
+
+/*
+ * removeTable called on transaction end, see call RegisterXactCallback() below
+ */
static void
removeTable(XactEvent event, void *arg)
{
static void
removeTable(XactEvent event, void *arg)
{
- List *toremove = arg;
ListCell *cell;
ListCell *cell;
- if (event != XACT_EVENT_COMMIT)
- return;
+ switch(event)
+ {
+ case XACT_EVENT_COMMIT:
+ break;
+ case XACT_EVENT_ABORT:
+ toremove = NIL;
+ default:
+ return;
+ }
foreach(cell, toremove)
{
foreach(cell, toremove)
{
@@
-768,6
+776,8
@@
removeTable(XactEvent event, void *arg)
hash_search(relstats, &relOid, HASH_REMOVE, NULL);
}
hash_search(relstats, &relOid, HASH_REMOVE, NULL);
}
+
+ toremove = NIL;
}
}
@@
-816,7
+826,6
@@
onlineAnalyzeHookerUtility(
((DropStmt*)parsetree)->removeType == OBJECT_TABLE)
{
ListCell *cell;
((DropStmt*)parsetree)->removeType == OBJECT_TABLE)
{
ListCell *cell;
- List *toremove = NIL;
foreach(cell, ((DropStmt*)parsetree)->objects)
{
foreach(cell, ((DropStmt*)parsetree)->objects)
{
@@
-833,9
+842,6
@@
onlineAnalyzeHookerUtility(
MemoryContextSwitchTo(ctx);
}
}
MemoryContextSwitchTo(ctx);
}
}
-
- if (list_length(toremove) > 0)
- RegisterXactCallback(removeTable, toremove);
}
else if (IsA(parsetree, VacuumStmt))
{
}
else if (IsA(parsetree, VacuumStmt))
{
@@
-1178,6
+1184,7
@@
_PG_init(void)
NULL
);
NULL
);
+ RegisterXactCallback(removeTable, NULL);
}
void _PG_fini(void);
}
void _PG_fini(void);