mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	Remove still more useless assignments.
Fix some more things scan-build pointed to as dead stores. In some of these cases, rearranging the code a little leads to more readable code IMO. It's all cosmetic, though. Discussion: https://postgr.es/m/CAEudQAo1+AcGppxDSg8k+zF4+Kv+eJyqzEDdbpDg58-=MQcerQ@mail.gmail.com
This commit is contained in:
		| @@ -518,9 +518,6 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto) | |||||||
| 		 */ | 		 */ | ||||||
| 		XLogBeginRead(ctx->reader, MyReplicationSlot->data.restart_lsn); | 		XLogBeginRead(ctx->reader, MyReplicationSlot->data.restart_lsn); | ||||||
|  |  | ||||||
| 		/* Initialize our return value in case we don't do anything */ |  | ||||||
| 		retlsn = MyReplicationSlot->data.confirmed_flush; |  | ||||||
|  |  | ||||||
| 		/* invalidate non-timetravel entries */ | 		/* invalidate non-timetravel entries */ | ||||||
| 		InvalidateSystemCaches(); | 		InvalidateSystemCaches(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6434,13 +6434,12 @@ float4_to_char(PG_FUNCTION_ARGS) | |||||||
| 	int			out_pre_spaces = 0, | 	int			out_pre_spaces = 0, | ||||||
| 				sign = 0; | 				sign = 0; | ||||||
| 	char	   *numstr, | 	char	   *numstr, | ||||||
| 			   *orgnum, |  | ||||||
| 			   *p; | 			   *p; | ||||||
|  |  | ||||||
| 	NUM_TOCHAR_prepare; | 	NUM_TOCHAR_prepare; | ||||||
|  |  | ||||||
| 	if (IS_ROMAN(&Num)) | 	if (IS_ROMAN(&Num)) | ||||||
| 		numstr = orgnum = int_to_roman((int) rint(value)); | 		numstr = int_to_roman((int) rint(value)); | ||||||
| 	else if (IS_EEEE(&Num)) | 	else if (IS_EEEE(&Num)) | ||||||
| 	{ | 	{ | ||||||
| 		if (isnan(value) || isinf(value)) | 		if (isnan(value) || isinf(value)) | ||||||
| @@ -6456,20 +6455,19 @@ float4_to_char(PG_FUNCTION_ARGS) | |||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			numstr = orgnum = psprintf("%+.*e", Num.post, value); | 			numstr = psprintf("%+.*e", Num.post, value); | ||||||
|  |  | ||||||
| 			/* | 			/* | ||||||
| 			 * Swap a leading positive sign for a space. | 			 * Swap a leading positive sign for a space. | ||||||
| 			 */ | 			 */ | ||||||
| 			if (*orgnum == '+') | 			if (*numstr == '+') | ||||||
| 				*orgnum = ' '; | 				*numstr = ' '; | ||||||
|  |  | ||||||
| 			numstr = orgnum; |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		float4		val = value; | 		float4		val = value; | ||||||
|  | 		char	   *orgnum; | ||||||
| 		int			numstr_pre_len; | 		int			numstr_pre_len; | ||||||
|  |  | ||||||
| 		if (IS_MULTI(&Num)) | 		if (IS_MULTI(&Num)) | ||||||
| @@ -6480,7 +6478,7 @@ float4_to_char(PG_FUNCTION_ARGS) | |||||||
| 			Num.pre += Num.multi; | 			Num.pre += Num.multi; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		orgnum = (char *) psprintf("%.0f", fabs(val)); | 		orgnum = psprintf("%.0f", fabs(val)); | ||||||
| 		numstr_pre_len = strlen(orgnum); | 		numstr_pre_len = strlen(orgnum); | ||||||
|  |  | ||||||
| 		/* adjust post digits to fit max float digits */ | 		/* adjust post digits to fit max float digits */ | ||||||
| @@ -6538,13 +6536,12 @@ float8_to_char(PG_FUNCTION_ARGS) | |||||||
| 	int			out_pre_spaces = 0, | 	int			out_pre_spaces = 0, | ||||||
| 				sign = 0; | 				sign = 0; | ||||||
| 	char	   *numstr, | 	char	   *numstr, | ||||||
| 			   *orgnum, |  | ||||||
| 			   *p; | 			   *p; | ||||||
|  |  | ||||||
| 	NUM_TOCHAR_prepare; | 	NUM_TOCHAR_prepare; | ||||||
|  |  | ||||||
| 	if (IS_ROMAN(&Num)) | 	if (IS_ROMAN(&Num)) | ||||||
| 		numstr = orgnum = int_to_roman((int) rint(value)); | 		numstr = int_to_roman((int) rint(value)); | ||||||
| 	else if (IS_EEEE(&Num)) | 	else if (IS_EEEE(&Num)) | ||||||
| 	{ | 	{ | ||||||
| 		if (isnan(value) || isinf(value)) | 		if (isnan(value) || isinf(value)) | ||||||
| @@ -6560,20 +6557,19 @@ float8_to_char(PG_FUNCTION_ARGS) | |||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			numstr = orgnum = (char *) psprintf("%+.*e", Num.post, value); | 			numstr = psprintf("%+.*e", Num.post, value); | ||||||
|  |  | ||||||
| 			/* | 			/* | ||||||
| 			 * Swap a leading positive sign for a space. | 			 * Swap a leading positive sign for a space. | ||||||
| 			 */ | 			 */ | ||||||
| 			if (*orgnum == '+') | 			if (*numstr == '+') | ||||||
| 				*orgnum = ' '; | 				*numstr = ' '; | ||||||
|  |  | ||||||
| 			numstr = orgnum; |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		float8		val = value; | 		float8		val = value; | ||||||
|  | 		char	   *orgnum; | ||||||
| 		int			numstr_pre_len; | 		int			numstr_pre_len; | ||||||
|  |  | ||||||
| 		if (IS_MULTI(&Num)) | 		if (IS_MULTI(&Num)) | ||||||
| @@ -6583,6 +6579,7 @@ float8_to_char(PG_FUNCTION_ARGS) | |||||||
| 			val = value * multi; | 			val = value * multi; | ||||||
| 			Num.pre += Num.multi; | 			Num.pre += Num.multi; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		orgnum = psprintf("%.0f", fabs(val)); | 		orgnum = psprintf("%.0f", fabs(val)); | ||||||
| 		numstr_pre_len = strlen(orgnum); | 		numstr_pre_len = strlen(orgnum); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4687,8 +4687,8 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, | |||||||
| 				rk1, | 				rk1, | ||||||
| 				rk2; | 				rk2; | ||||||
|  |  | ||||||
| 	r1 = rk1 = JsonbIteratorNext(it1, &v1, false); | 	rk1 = JsonbIteratorNext(it1, &v1, false); | ||||||
| 	r2 = rk2 = JsonbIteratorNext(it2, &v2, false); | 	rk2 = JsonbIteratorNext(it2, &v2, false); | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Both elements are objects. | 	 * Both elements are objects. | ||||||
| @@ -4696,15 +4696,15 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, | |||||||
| 	if (rk1 == WJB_BEGIN_OBJECT && rk2 == WJB_BEGIN_OBJECT) | 	if (rk1 == WJB_BEGIN_OBJECT && rk2 == WJB_BEGIN_OBJECT) | ||||||
| 	{ | 	{ | ||||||
| 		/* | 		/* | ||||||
| 		 * Append the all tokens from v1 to res, except last WJB_END_OBJECT | 		 * Append all the tokens from v1 to res, except last WJB_END_OBJECT | ||||||
| 		 * (because res will not be finished yet). | 		 * (because res will not be finished yet). | ||||||
| 		 */ | 		 */ | ||||||
| 		pushJsonbValue(state, r1, NULL); | 		pushJsonbValue(state, rk1, NULL); | ||||||
| 		while ((r1 = JsonbIteratorNext(it1, &v1, true)) != WJB_END_OBJECT) | 		while ((r1 = JsonbIteratorNext(it1, &v1, true)) != WJB_END_OBJECT) | ||||||
| 			pushJsonbValue(state, r1, &v1); | 			pushJsonbValue(state, r1, &v1); | ||||||
|  |  | ||||||
| 		/* | 		/* | ||||||
| 		 * Append the all tokens from v2 to res, include last WJB_END_OBJECT | 		 * Append all the tokens from v2 to res, include last WJB_END_OBJECT | ||||||
| 		 * (the concatenation will be completed). | 		 * (the concatenation will be completed). | ||||||
| 		 */ | 		 */ | ||||||
| 		while ((r2 = JsonbIteratorNext(it2, &v2, true)) != WJB_DONE) | 		while ((r2 = JsonbIteratorNext(it2, &v2, true)) != WJB_DONE) | ||||||
| @@ -4716,7 +4716,7 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, | |||||||
| 	 */ | 	 */ | ||||||
| 	else if (rk1 == WJB_BEGIN_ARRAY && rk2 == WJB_BEGIN_ARRAY) | 	else if (rk1 == WJB_BEGIN_ARRAY && rk2 == WJB_BEGIN_ARRAY) | ||||||
| 	{ | 	{ | ||||||
| 		pushJsonbValue(state, r1, NULL); | 		pushJsonbValue(state, rk1, NULL); | ||||||
|  |  | ||||||
| 		while ((r1 = JsonbIteratorNext(it1, &v1, true)) != WJB_END_ARRAY) | 		while ((r1 = JsonbIteratorNext(it1, &v1, true)) != WJB_END_ARRAY) | ||||||
| 		{ | 		{ | ||||||
| @@ -4736,10 +4736,8 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2, | |||||||
| 	else if (((rk1 == WJB_BEGIN_ARRAY && !(*it1)->isScalar) && rk2 == WJB_BEGIN_OBJECT) || | 	else if (((rk1 == WJB_BEGIN_ARRAY && !(*it1)->isScalar) && rk2 == WJB_BEGIN_OBJECT) || | ||||||
| 			 (rk1 == WJB_BEGIN_OBJECT && (rk2 == WJB_BEGIN_ARRAY && !(*it2)->isScalar))) | 			 (rk1 == WJB_BEGIN_OBJECT && (rk2 == WJB_BEGIN_ARRAY && !(*it2)->isScalar))) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
| 		JsonbIterator **it_array = rk1 == WJB_BEGIN_ARRAY ? it1 : it2; | 		JsonbIterator **it_array = rk1 == WJB_BEGIN_ARRAY ? it1 : it2; | ||||||
| 		JsonbIterator **it_object = rk1 == WJB_BEGIN_OBJECT ? it1 : it2; | 		JsonbIterator **it_object = rk1 == WJB_BEGIN_OBJECT ? it1 : it2; | ||||||
|  |  | ||||||
| 		bool		prepend = (rk1 == WJB_BEGIN_OBJECT); | 		bool		prepend = (rk1 == WJB_BEGIN_OBJECT); | ||||||
|  |  | ||||||
| 		pushJsonbValue(state, WJB_BEGIN_ARRAY, NULL); | 		pushJsonbValue(state, WJB_BEGIN_ARRAY, NULL); | ||||||
|   | |||||||
| @@ -408,7 +408,6 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts, | |||||||
| 	int			i; | 	int			i; | ||||||
| 	int			ntups; | 	int			ntups; | ||||||
| 	bool		failed = false; | 	bool		failed = false; | ||||||
| 	bool		parallel = concurrentCons > 1; |  | ||||||
| 	bool		tables_listed = false; | 	bool		tables_listed = false; | ||||||
| 	bool		has_where = false; | 	bool		has_where = false; | ||||||
| 	const char *stage_commands[] = { | 	const char *stage_commands[] = { | ||||||
| @@ -651,25 +650,19 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts, | |||||||
| 	PQclear(res); | 	PQclear(res); | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * If there are more connections than vacuumable relations, we don't need | 	 * Ensure concurrentCons is sane.  If there are more connections than | ||||||
| 	 * to use them all. | 	 * vacuumable relations, we don't need to use them all. | ||||||
| 	 */ | 	 */ | ||||||
| 	if (parallel) |  | ||||||
| 	{ |  | ||||||
| 	if (concurrentCons > ntups) | 	if (concurrentCons > ntups) | ||||||
| 		concurrentCons = ntups; | 		concurrentCons = ntups; | ||||||
| 		if (concurrentCons <= 1) | 	if (concurrentCons <= 0) | ||||||
| 			parallel = false; | 		concurrentCons = 1; | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Setup the database connections. We reuse the connection we already have | 	 * Setup the database connections. We reuse the connection we already have | ||||||
| 	 * for the first slot.  If not in parallel mode, the first slot in the | 	 * for the first slot.  If not in parallel mode, the first slot in the | ||||||
| 	 * array contains the connection. | 	 * array contains the connection. | ||||||
| 	 */ | 	 */ | ||||||
| 	if (concurrentCons <= 0) |  | ||||||
| 		concurrentCons = 1; |  | ||||||
|  |  | ||||||
| 	slots = ParallelSlotsSetup(dbname, host, port, username, prompt_password, | 	slots = ParallelSlotsSetup(dbname, host, port, username, prompt_password, | ||||||
| 							   progname, echo, conn, concurrentCons); | 							   progname, echo, conn, concurrentCons); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user