Some improvements and fixes to previously submitted pull request for cleaning temporary objects
This commit is contained in:
		| @ -243,7 +243,7 @@ static char * | |||||||
| utoa(unsigned int value, char *buffer) | utoa(unsigned int value, char *buffer) | ||||||
| { | { | ||||||
| 	sprintf(buffer, "%u", value); | 	sprintf(buffer, "%u", value); | ||||||
| 	return strdup(buffer); | 	return pgut_strdup(buffer); | ||||||
| } | } | ||||||
|  |  | ||||||
| static pgut_option options[] = | static pgut_option options[] = | ||||||
| @ -1391,6 +1391,7 @@ repack_one_table(repack_table *table, const char *orderby) | |||||||
| 	params[1] = utoa(temp_obj_num, buffer); | 	params[1] = utoa(temp_obj_num, buffer); | ||||||
| 	command("SELECT repack.repack_drop($1, $2)", 2, params); | 	command("SELECT repack.repack_drop($1, $2)", 2, params); | ||||||
| 	command("COMMIT", 0, NULL); | 	command("COMMIT", 0, NULL); | ||||||
|  | 	temp_obj_num = 0; /* reset temporary object counter after cleanup */ | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * 7. Analyze. | 	 * 7. Analyze. | ||||||
| @ -1706,6 +1707,7 @@ repack_cleanup_callback(bool fatal, void *userdata) | |||||||
|  |  | ||||||
| 		reconnect(ERROR); | 		reconnect(ERROR); | ||||||
| 		command("SELECT repack.repack_drop($1, $2)", 2, params); | 		command("SELECT repack.repack_drop($1, $2)", 2, params); | ||||||
|  | 		temp_obj_num = 0; /* reset temporary object counter after cleanup */ | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -1734,6 +1736,7 @@ repack_cleanup(bool fatal, const repack_table *table) | |||||||
| 		params[0] = utoa(table->target_oid, buffer); | 		params[0] = utoa(table->target_oid, buffer); | ||||||
| 		params[1] =  utoa(temp_obj_num, buffer); | 		params[1] =  utoa(temp_obj_num, buffer); | ||||||
| 		command("SELECT repack.repack_drop($1, $2)", 2, params); | 		command("SELECT repack.repack_drop($1, $2)", 2, params); | ||||||
|  | 		temp_obj_num = 0; /* reset temporary object counter after cleanup */ | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -64,7 +64,7 @@ static void on_before_exec(pgutConn *conn); | |||||||
| static void on_after_exec(pgutConn *conn); | static void on_after_exec(pgutConn *conn); | ||||||
| static void on_interrupt(void); | static void on_interrupt(void); | ||||||
| static void on_cleanup(void); | static void on_cleanup(void); | ||||||
| static void exit_or_abort(int exitcode); | static void exit_or_abort(int exitcode, int elevel); | ||||||
|  |  | ||||||
| void | void | ||||||
| pgut_init(int argc, char **argv) | pgut_init(int argc, char **argv) | ||||||
| @ -872,7 +872,10 @@ pgut_errfinish(int dummy, ...) | |||||||
| 			edata->detail.data); | 			edata->detail.data); | ||||||
|  |  | ||||||
| 	if (pgut_abort_level <= edata->elevel && edata->elevel <= PANIC) | 	if (pgut_abort_level <= edata->elevel && edata->elevel <= PANIC) | ||||||
| 		exit_or_abort(edata->code); | 	{ | ||||||
|  | 		in_cleanup = true; /* need to be set for cleaning temporary objects on error */ | ||||||
|  | 		exit_or_abort(edata->code, edata->elevel); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifndef PGUT_OVERRIDE_ELOG | #ifndef PGUT_OVERRIDE_ELOG | ||||||
| @ -1195,13 +1198,19 @@ on_cleanup(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| exit_or_abort(int exitcode) | exit_or_abort(int exitcode, int elevel) | ||||||
| { | { | ||||||
| 	call_atexit_callbacks(true); | 	 | ||||||
| 	if (in_cleanup) | 	if (in_cleanup && FATAL > elevel) | ||||||
| 	{ | 	{ | ||||||
| 		/* oops, error in cleanup*/ | 		/* oops, error in cleanup*/ | ||||||
| 		in_cleanup = false; | 		call_atexit_callbacks(true); | ||||||
|  | 		exit(exitcode); | ||||||
|  | 	} | ||||||
|  | 	else if (FATAL <= elevel <= PANIC) | ||||||
|  | 	{ | ||||||
|  | 		/* on FATAL or PANIC */ | ||||||
|  | 		call_atexit_callbacks(true); | ||||||
| 		abort(); | 		abort(); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user