/* * InitCatalogCachePhase2 - finish initializing the caches * * Finish initializing all the caches, including necessary database * access. * * This is *not* essential; normally we allow syscaches to be initialized * on first use. However, it is useful as a mechanism to preload the * relcache with entries for the most-commonly-used system catalogs. * Therefore, we invoke this routine when we need to write a new relcache * init file. */ void InitCatalogCachePhase2(void) { int cacheId; Assert(CacheInitialized); for (cacheId = 0; cacheId < SysCacheSize; cacheId++) { /* * In order for upgrade to work successfully we must be able to run * in single user mode with a catalog like the GP 3.2 catalog. To * support this we must skip the optional syscache initialization * for catalog tables that did not exist in 3.2, otherwise we will * try to read the relation before we have created it and will fail * to startup. */ if ((IsBootstrapProcessingMode() || IsInitProcessingMode()) && ((cacheinfo[cacheId].reloid == ForeignDataWrapperRelationId) || (cacheinfo[cacheId].reloid == ForeignServerRelationId) || (cacheinfo[cacheId].reloid == UserMappingRelationId))) { continue; } InitCatCachePhase2(SysCache[cacheId], true); } }
/* * This routine loads a previous postmaster dump of its non-default * settings. */ void read_nondefault_variables(void) { FILE *fp; char *varname, *varvalue, *varsourcefile; int varsourceline; GucSource varsource; GucContext varscontext; /* * Assert that PGC_BACKEND/PGC_SU_BACKEND case in set_config_option() will * do the right thing. */ Assert(IsInitProcessingMode()); /* * Open file */ fp = AllocateFile(CONFIG_EXEC_PARAMS, "r"); if (!fp) { /* File not found is fine */ if (errno != ENOENT) ereport(FATAL, (errcode_for_file_access(), errmsg("could not read from file \"%s\": %m", CONFIG_EXEC_PARAMS))); return; } for (;;) { struct config_generic *record; if ((varname = read_string_with_null(fp)) == NULL) break; if ((record = find_option(varname, true, FATAL)) == NULL) elog(FATAL, "failed to locate variable \"%s\" in exec config params file", varname); if ((varvalue = read_string_with_null(fp)) == NULL) elog(FATAL, "invalid format of exec config params file"); if ((varsourcefile = read_string_with_null(fp)) == NULL) elog(FATAL, "invalid format of exec config params file"); if (fread(&varsourceline, 1, sizeof(varsourceline), fp) != sizeof(varsourceline)) elog(FATAL, "invalid format of exec config params file"); if (fread(&varsource, 1, sizeof(varsource), fp) != sizeof(varsource)) elog(FATAL, "invalid format of exec config params file"); if (fread(&varscontext, 1, sizeof(varscontext), fp) != sizeof(varscontext)) elog(FATAL, "invalid format of exec config params file"); (void) set_config_option(varname, varvalue, varscontext, varsource, GUC_ACTION_SET, true, 0, true); if (varsourcefile[0]) set_config_sourcefile(varname, varsourcefile, varsourceline); free(varname); free(varvalue); free(varsourcefile); } FreeFile(fp); }