diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index ad8c176793..9dabfc0d36 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1416,6 +1416,19 @@ ExecuteTruncate(TruncateStmt *stmt) /* find_all_inheritors already got lock */ rel = heap_open(childrelid, NoLock); + + /* + * It is possible that the parent table has children that are temp + * tables of other backends. We cannot safely access such tables + * (because of buffering issues), and the best thing to do seems + * to be to silently ignore them. + */ + if (RELATION_IS_OTHER_TEMP(newrelation)) + { + heap_close(rel); + continue; + } + truncate_check_rel(RelationGetRelid(rel), rel->rd_rel); truncate_check_activity(rel);