* formrdesc * * This is a special cut-down version of RelationBuildDesc(), * used while initializing the relcache. * The relation descriptor is built just from the supplied parameters, * without actually looking at any system table entries. We cheat * quite a lot since we only need to work for a few basic system * catalogs. * * The catalogs this is used for can't have constraints
| 1922 | * NOTE: we assume we are already switched into CacheMemoryContext. |
| 1923 | */ |
| 1924 | static void |
| 1925 | formrdesc(const char *relationName, Oid relationReltype, |
| 1926 | bool isshared, |
| 1927 | int natts, const FormData_pg_attribute *attrs) |
| 1928 | { |
| 1929 | Relation relation; |
| 1930 | int i; |
| 1931 | bool has_not_null; |
| 1932 | |
| 1933 | /* |
| 1934 | * allocate new relation desc, clear all fields of reldesc |
| 1935 | */ |
| 1936 | relation = (Relation) palloc0(sizeof(RelationData)); |
| 1937 | |
| 1938 | /* make sure relation is marked as having no open file yet */ |
| 1939 | relation->rd_smgr = NULL; |
| 1940 | |
| 1941 | /* |
| 1942 | * initialize reference count: 1 because it is nailed in cache |
| 1943 | */ |
| 1944 | relation->rd_refcnt = 1; |
| 1945 | |
| 1946 | /* |
| 1947 | * all entries built with this routine are nailed-in-cache; none are for |
| 1948 | * new or temp relations. |
| 1949 | */ |
| 1950 | relation->rd_isnailed = true; |
| 1951 | relation->rd_createSubid = InvalidSubTransactionId; |
| 1952 | relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; |
| 1953 | relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId; |
| 1954 | relation->rd_droppedSubid = InvalidSubTransactionId; |
| 1955 | relation->rd_backend = InvalidBackendId; |
| 1956 | relation->rd_islocaltemp = false; |
| 1957 | |
| 1958 | /* |
| 1959 | * initialize relation tuple form |
| 1960 | * |
| 1961 | * The data we insert here is pretty incomplete/bogus, but it'll serve to |
| 1962 | * get us launched. RelationCacheInitializePhase3() will read the real |
| 1963 | * data from pg_class and replace what we've done here. Note in |
| 1964 | * particular that relowner is left as zero; this cues |
| 1965 | * RelationCacheInitializePhase3 that the real data isn't there yet. |
| 1966 | */ |
| 1967 | relation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); |
| 1968 | |
| 1969 | namestrcpy(&relation->rd_rel->relname, relationName); |
| 1970 | relation->rd_rel->relnamespace = PG_CATALOG_NAMESPACE; |
| 1971 | relation->rd_rel->reltype = relationReltype; |
| 1972 | |
| 1973 | /* |
| 1974 | * It's important to distinguish between shared and non-shared relations, |
| 1975 | * even at bootstrap time, to make sure we know where they are stored. |
| 1976 | */ |
| 1977 | relation->rd_rel->relisshared = isshared; |
| 1978 | if (isshared) |
| 1979 | relation->rd_rel->reltablespace = GLOBALTABLESPACE_OID; |
| 1980 | |
| 1981 | /* formrdesc is used only for permanent relations */ |
no test coverage detected