MCPcopy Create free account
hub / github.com/apache/cloudberry / load_libraries

Function load_libraries

src/backend/utils/init/miscinit.c:1836–1883  ·  view source on GitHub ↗

* load the shared libraries listed in 'libraries' * * 'gucname': name of GUC variable, for error reports * 'restricted': if true, force libraries to be in $libdir/plugins/ */

Source from the content-addressed store, hash-verified

1834 * 'restricted': if true, force libraries to be in $libdir/plugins/
1835 */
1836static void
1837load_libraries(const char *libraries, const char *gucname, bool restricted)
1838{
1839 char *rawstring;
1840 List *elemlist;
1841 ListCell *l;
1842
1843 if (libraries == NULL || libraries[0] == '\0')
1844 return; /* nothing to do */
1845
1846 /* Need a modifiable copy of string */
1847 rawstring = pstrdup(libraries);
1848
1849 /* Parse string into list of filename paths */
1850 if (!SplitDirectoriesString(rawstring, ',', &elemlist))
1851 {
1852 /* syntax error in list */
1853 list_free_deep(elemlist);
1854 pfree(rawstring);
1855 ereport(LOG,
1856 (errcode(ERRCODE_SYNTAX_ERROR),
1857 errmsg("invalid list syntax in parameter \"%s\"",
1858 gucname)));
1859 return;
1860 }
1861
1862 foreach(l, elemlist)
1863 {
1864 /* Note that filename was already canonicalized */
1865 char *filename = (char *) lfirst(l);
1866 char *expanded = NULL;
1867
1868 /* If restricting, insert $libdir/plugins if not mentioned already */
1869 if (restricted && first_dir_separator(filename) == NULL)
1870 {
1871 expanded = psprintf("$libdir/plugins/%s", filename);
1872 filename = expanded;
1873 }
1874 load_file(filename, restricted);
1875 ereport(DEBUG1,
1876 (errmsg_internal("loaded library \"%s\"", filename)));
1877 if (expanded)
1878 pfree(expanded);
1879 }
1880
1881 list_free_deep(elemlist);
1882 pfree(rawstring);
1883}
1884
1885/*
1886 * process any libraries that should be preloaded at postmaster start

Calls 11

SplitDirectoriesStringFunction · 0.85
list_free_deepFunction · 0.85
first_dir_separatorFunction · 0.85
psprintfFunction · 0.85
load_fileFunction · 0.85
pstrdupFunction · 0.50
pfreeFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50
foreachFunction · 0.50
errmsg_internalFunction · 0.50

Tested by

no test coverage detected