|
42 | 42 | *
|
43 | 43 | *
|
44 | 44 | * IDENTIFICATION
|
45 |
| - * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.183 2007/03/02 23:37:23 tgl Exp $ |
| 45 | + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.184 2007/05/02 15:32:41 tgl Exp $ |
46 | 46 | *
|
47 | 47 | *-------------------------------------------------------------------------
|
48 | 48 | */
|
@@ -1099,6 +1099,61 @@ ReThrowError(ErrorData *edata)
|
1099 | 1099 | PG_RE_THROW();
|
1100 | 1100 | }
|
1101 | 1101 |
|
| 1102 | +/* |
| 1103 | + * pg_re_throw --- out-of-line implementation of PG_RE_THROW() macro |
| 1104 | + */ |
| 1105 | +void |
| 1106 | +pg_re_throw(void) |
| 1107 | +{ |
| 1108 | + /* If possible, throw the error to the next outer setjmp handler */ |
| 1109 | + if (PG_exception_stack != NULL) |
| 1110 | + siglongjmp(*PG_exception_stack, 1); |
| 1111 | + else |
| 1112 | + { |
| 1113 | + /* |
| 1114 | + * If we get here, elog(ERROR) was thrown inside a PG_TRY block, which |
| 1115 | + * we have now exited only to discover that there is no outer setjmp |
| 1116 | + * handler to pass the error to. Had the error been thrown outside the |
| 1117 | + * block to begin with, we'd have promoted the error to FATAL, so the |
| 1118 | + * correct behavior is to make it FATAL now; that is, emit it and then |
| 1119 | + * call proc_exit. |
| 1120 | + */ |
| 1121 | + ErrorData *edata = &errordata[errordata_stack_depth]; |
| 1122 | + |
| 1123 | + Assert(errordata_stack_depth >= 0); |
| 1124 | + Assert(edata->elevel == ERROR); |
| 1125 | + edata->elevel = FATAL; |
| 1126 | + |
| 1127 | + /* |
| 1128 | + * At least in principle, the increase in severity could have changed |
| 1129 | + * where-to-output decisions, so recalculate. This should stay in |
| 1130 | + * sync with errstart(), which see for comments. |
| 1131 | + */ |
| 1132 | + if (IsPostmasterEnvironment) |
| 1133 | + edata->output_to_server = is_log_level_output(FATAL, |
| 1134 | + log_min_messages); |
| 1135 | + else |
| 1136 | + edata->output_to_server = (FATAL >= log_min_messages); |
| 1137 | + if (whereToSendOutput == DestRemote) |
| 1138 | + { |
| 1139 | + if (ClientAuthInProgress) |
| 1140 | + edata->output_to_client = true; |
| 1141 | + else |
| 1142 | + edata->output_to_client = (FATAL >= client_min_messages); |
| 1143 | + } |
| 1144 | + |
| 1145 | + /* |
| 1146 | + * We can use errfinish() for the rest, but we don't want it to call |
| 1147 | + * any error context routines a second time. Since we know we are |
| 1148 | + * about to exit, it should be OK to just clear the context stack. |
| 1149 | + */ |
| 1150 | + error_context_stack = NULL; |
| 1151 | + |
| 1152 | + errfinish(0); |
| 1153 | + } |
| 1154 | +} |
| 1155 | + |
| 1156 | + |
1102 | 1157 | /*
|
1103 | 1158 | * Initialization of error output file
|
1104 | 1159 | */
|
|
0 commit comments