• 模式的删除与dodeletion


    代码位于src/backend/catalog/dependency.c,这里有一个 dodeletion 函数。

    不过这个函数是通用的。

    [作者:技术者高健@博客园  mail: luckyjackgao@gmail.com ]

    /*                            
     * doDeletion: actually delete a single object                            
     */                            
    static void                            
    doDeletion(const ObjectAddress *object, int flags)                            
    {                            
        switch (getObjectClass(object))                        
        {                        
            ……                    
            case OCLASS_SCHEMA:                    
                RemoveSchemaById(object->objectId);                
                break;                
                                
            ……                    
            default:                    
                elog(ERROR, "unrecognized object class: %u",                
                     object->classId);            
        }                        
    }                            

    而它又是被 depency.c 中的 deleteOneObject 调用

    /*                            
     * deleteOneObject: delete a single object for performDeletion.                            
     *                            
     * depRel is the already-open pg_depend relation.                            
     */                            
    static void                            
    deleteOneObject(const ObjectAddress *object, Relation depRel, int flags)                            
    {                            
        ……                        
        /*                        
         * Now delete the object itself, in an object-type-dependent way.                        
         */                        
        doDeletion(object, flags);                        
                                
        ……                        
        /*                        
         * And we're done!                        
         */                        
    }                            

    而它又是被 performDeletion 所调用:

    /*                            
     * performDeletion: attempt to drop the specified object.  If CASCADE                            
     * behavior is specified, also drop any dependent objects (recursively).                            
     * If RESTRICT behavior is specified, error out if there are any dependent                            
     * objects, except for those that should be implicitly dropped anyway                            
     * according to the dependency type.                            
     *                            
     * This is the outer control routine for all forms of DROP that drop objects                            
     * that can participate in dependencies.  Note that the next two routines                            
     * are variants on the same theme; if you change anything here you'll likely                            
     * need to fix them too.                            
     *                            
     * flags should include PERFORM_DELETION_INTERNAL when the drop operation is                            
     * not the direct result of a user-initiated action.  For example, when a                            
     * temporary schema is cleaned out so that a new backend can use it, or when                            
     * a column default is dropped as an intermediate step while adding a new one,                            
     * that's an internal operation.  On the other hand, when the we drop something                            
     * because the user issued a DROP statement against it, that's not internal.                            
     */                            
    void                            
    performDeletion(const ObjectAddress *object,                            
                    DropBehavior behavior, int flags)            
    {                            
        ……                        
        /*                        
         * Delete all the objects in the proper order.                        
         */                        
        for (i = 0; i < targetObjects->numrefs; i++)                        
        {                        
            ObjectAddress *thisobj = targetObjects->refs + i;                    
                                
            deleteOneObject(thisobj, depRel, flags);                    
        }                        
                                
        /* And clean up */                        
        free_object_addresses(targetObjects);                        
                                
        heap_close(depRel, RowExclusiveLock);                        
    }                            

    今后继续。

    [作者:技术者高健@博客园  mail: luckyjackgao@gmail.com ]

  • 相关阅读:
    欧几里得算法&&扩展欧几里得算法
    POJ-1006 Biorhythms (生物节律)
    第3周实践项目7 删除链表元素最大值
    第3周实践项目1 顺序表的基本运算
    第三周项目4(2)-顺序表应用 将所有奇数移到所有偶数前面
    第3周实践项目5 -顺序表的应用 拆分单链表
    SDUT-2144 图结构练习——最小生成树
    SDUT-3362 数据结构实验之图论六:村村通公路
    Codeforces Round #616 (Div. 2)题解
    1.29 educational round 81
  • 原文地址:https://www.cnblogs.com/gaojian/p/2740938.html
Copyright © 2020-2023  润新知