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

Function PrepareTempTablespaces

src/backend/commands/tablespace.c:1888–1974  ·  view source on GitHub ↗

* PrepareTempTablespaces -- prepare to use temp tablespaces * * If we have not already done so in the current transaction, parse the * temp_tablespaces GUC variable and tell fd.c which tablespace(s) to use * for temp files. */

Source from the content-addressed store, hash-verified

1886 * for temp files.
1887 */
1888void
1889PrepareTempTablespaces(void)
1890{
1891 char *rawname;
1892 List *namelist;
1893 Oid *tblSpcs;
1894 int numSpcs;
1895 ListCell *l;
1896
1897 /* No work if already done in current transaction */
1898 if (TempTablespacesAreSet())
1899 return;
1900
1901 /*
1902 * Can't do catalog access unless within a transaction. This is just a
1903 * safety check in case this function is called by low-level code that
1904 * could conceivably execute outside a transaction. Note that in such a
1905 * scenario, fd.c will fall back to using the current database's default
1906 * tablespace, which should always be OK.
1907 */
1908 if (!IsTransactionState())
1909 return;
1910
1911 /* Need a modifiable copy of string */
1912 rawname = pstrdup(temp_tablespaces);
1913
1914 /* Parse string into list of identifiers */
1915 if (!SplitIdentifierString(rawname, ',', &namelist))
1916 {
1917 /* syntax error in name list */
1918 SetTempTablespaces(NULL, 0);
1919 pfree(rawname);
1920 list_free(namelist);
1921 return;
1922 }
1923
1924 /* Store tablespace OIDs in an array in TopTransactionContext */
1925 tblSpcs = (Oid *) MemoryContextAlloc(TopTransactionContext,
1926 list_length(namelist) * sizeof(Oid));
1927 numSpcs = 0;
1928 foreach(l, namelist)
1929 {
1930 char *curname = (char *) lfirst(l);
1931 Oid curoid;
1932 AclResult aclresult;
1933
1934 /* Allow an empty string (signifying database default) */
1935 if (curname[0] == '\0')
1936 {
1937 /* InvalidOid signifies database's default tablespace */
1938 tblSpcs[numSpcs++] = InvalidOid;
1939 continue;
1940 }
1941
1942 /* Else verify that name is a valid tablespace name */
1943 curoid = get_tablespace_oid(curname, true);
1944 if (curoid == InvalidOid)
1945 {

Callers 9

tuplestore_make_sharedFunction · 0.85
tuplestore_make_sharedV2Function · 0.85
inittapestateFunction · 0.85
GetDefaultTablespaceFunction · 0.85
BufFileCreateTempInSetFunction · 0.85
SharedFileSetInitFunction · 0.85
ExecHashTableCreateFunction · 0.85

Calls 13

TempTablespacesAreSetFunction · 0.85
IsTransactionStateFunction · 0.85
SplitIdentifierStringFunction · 0.85
SetTempTablespacesFunction · 0.85
MemoryContextAllocFunction · 0.85
list_lengthFunction · 0.85
get_tablespace_oidFunction · 0.85
pg_tablespace_aclcheckFunction · 0.85
GetUserIdFunction · 0.85
pstrdupFunction · 0.50
pfreeFunction · 0.50
list_freeFunction · 0.50

Tested by

no test coverage detected