* ThrowErrorData --- report an error described by an ErrorData structure * * This is somewhat like ReThrowError, but it allows elevels besides ERROR, * and the boolean flags such as output_to_server are computed via the * default rules rather than being copied from the given ErrorData. * This is primarily used to re-report errors originally reported by * background worker processes and then
| 1940 | * modification) to the backend responsible for them. |
| 1941 | */ |
| 1942 | void |
| 1943 | ThrowErrorData(ErrorData *edata) |
| 1944 | { |
| 1945 | ErrorData *newedata; |
| 1946 | MemoryContext oldcontext; |
| 1947 | |
| 1948 | if (!errstart(edata->elevel, edata->domain)) |
| 1949 | return; /* error is not to be reported at all */ |
| 1950 | |
| 1951 | newedata = &errordata[errordata_stack_depth]; |
| 1952 | recursion_depth++; |
| 1953 | oldcontext = MemoryContextSwitchTo(newedata->assoc_context); |
| 1954 | |
| 1955 | /* Copy the supplied fields to the error stack entry. */ |
| 1956 | if (edata->sqlerrcode != 0) |
| 1957 | newedata->sqlerrcode = edata->sqlerrcode; |
| 1958 | if (edata->message) |
| 1959 | newedata->message = pstrdup(edata->message); |
| 1960 | if (edata->detail) |
| 1961 | newedata->detail = pstrdup(edata->detail); |
| 1962 | if (edata->detail_log) |
| 1963 | newedata->detail_log = pstrdup(edata->detail_log); |
| 1964 | if (edata->hint) |
| 1965 | newedata->hint = pstrdup(edata->hint); |
| 1966 | if (edata->context) |
| 1967 | newedata->context = pstrdup(edata->context); |
| 1968 | if (edata->backtrace) |
| 1969 | newedata->backtrace = pstrdup(edata->backtrace); |
| 1970 | /* assume message_id is not available */ |
| 1971 | if (edata->schema_name) |
| 1972 | newedata->schema_name = pstrdup(edata->schema_name); |
| 1973 | if (edata->table_name) |
| 1974 | newedata->table_name = pstrdup(edata->table_name); |
| 1975 | if (edata->column_name) |
| 1976 | newedata->column_name = pstrdup(edata->column_name); |
| 1977 | if (edata->datatype_name) |
| 1978 | newedata->datatype_name = pstrdup(edata->datatype_name); |
| 1979 | if (edata->constraint_name) |
| 1980 | newedata->constraint_name = pstrdup(edata->constraint_name); |
| 1981 | newedata->cursorpos = edata->cursorpos; |
| 1982 | newedata->internalpos = edata->internalpos; |
| 1983 | if (edata->internalquery) |
| 1984 | newedata->internalquery = pstrdup(edata->internalquery); |
| 1985 | |
| 1986 | MemoryContextSwitchTo(oldcontext); |
| 1987 | recursion_depth--; |
| 1988 | |
| 1989 | /* Process the error. */ |
| 1990 | errfinish(edata->filename, edata->lineno, edata->funcname); |
| 1991 | } |
| 1992 | |
| 1993 | /* |
| 1994 | * ReThrowError --- re-throw a previously copied error |
no test coverage detected