zoukankan      html  css  js  c++  java
  • PostreSQL 的模式创建的代码位于何处

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

    主要代码在 src/backend/catalog/pg_namespace.c

    /* ----------------                        
     * NamespaceCreate                        
     *                        
     * Create a namespace (schema) with the given name and owner OID.                        
     *                        
     * If isTemp is true, this schema is a per-backend schema for holding                        
     * temporary tables.  Currently, the only effect of that is to prevent it                        
     * from being linked as a member of any active extension.  (If someone                        
     * does CREATE TEMP TABLE in an extension script, we don't want the temp                        
     * schema to become part of the extension.)                        
     * ---------------                        
     */                        
    Oid                        
    NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)                        
    {                        
        ……                    
        nspoid = simple_heap_insert(nspdesc, tup);                    
        Assert(OidIsValid(nspoid));                    
                            
        CatalogUpdateIndexes(nspdesc, tup);                    
                            
        heap_close(nspdesc, RowExclusiveLock);                    
                            
        /* Record dependencies */                    
        myself.classId = NamespaceRelationId;                    
        myself.objectId = nspoid;                    
        myself.objectSubId = 0;                    
                            
        /* dependency on owner */                    
        recordDependencyOnOwner(NamespaceRelationId, nspoid, ownerId);                    
                            
        /* dependency on extension ... but not for magic temp schemas */                    
        if (!isTemp)                    
            recordDependencyOnCurrentExtension(&myself, false);                
                            
        /* Post creation hook for new schema */                    
        InvokeObjectAccessHook(OAT_POST_CREATE,                    
                       NamespaceRelationId, nspoid, 0, NULL);        
                            
        return nspoid;                    
        ……                    
    }                        
    NamespaceCreate 被 src/backend/commands/schemacmds.c 的 CreateSchemaCommand 调用
    /*                            
     * CREATE SCHEMA                            
     */                            
    void                            
    CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)                            
    {                            
        ……                        
        /* Create the schema's namespace */                        
        namespaceId = NamespaceCreate(schemaName, owner_uid, false);                        
                                
        /* Advance cmd counter to make the namespace visible */                        
        CommandCounterIncrement();                        
        ……                        
    }                            

    接下来,我特别想知道,得到的 oid ,被用到了什么地方,以何种方式存储。

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

     

  • 相关阅读:
    如何把阿里图标库的图标生成代码并应用于自己的项目
    【记事件】
    极光推送,为什么IOS有的手机一直收不到推送。
    浮点型的数据对比。
    MySQL通过show processlist查看项目的mysql写的有问题
    thinkPHP5实现简单的多图上传
    mac终端运行/终止jar包
    referer参数和addslashes()函数的骚路子
    小技巧|addslashes绕过
    团队博客七
  • 原文地址:https://www.cnblogs.com/gaojian/p/2740700.html
Copyright © 2011-2022 走看看