mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Make sure that debug_query_string contains the original query text,
if available (which it usually should be), during processing of Bind and Execute protocol messages. This improves usefulness of log_min_error_statement logging for extended query protocol.
This commit is contained in:
		
							parent
							
								
									def651f48f
								
							
						
					
					
						commit
						681892208f
					
				| @ -8,7 +8,7 @@ | ||||
|  * | ||||
|  * | ||||
|  * IDENTIFICATION | ||||
|  *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.515 2006/10/08 17:45:50 momjian Exp $ | ||||
|  *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.516 2006/10/19 19:52:22 tgl Exp $ | ||||
|  * | ||||
|  * NOTES | ||||
|  *	  this is the "main" module of the postgres backend and | ||||
| @ -1326,9 +1326,9 @@ exec_bind_message(StringInfo input_message) | ||||
| 	/*
 | ||||
| 	 * Report query to various monitoring facilities. | ||||
| 	 */ | ||||
| 	debug_query_string = "bind message"; | ||||
| 	debug_query_string = pstmt->query_string ? pstmt->query_string : "<BIND>"; | ||||
| 
 | ||||
| 	pgstat_report_activity(pstmt->query_string ? pstmt->query_string : "<BIND>"); | ||||
| 	pgstat_report_activity(debug_query_string); | ||||
| 
 | ||||
| 	set_ps_display("BIND", false); | ||||
| 
 | ||||
| @ -1680,29 +1680,9 @@ exec_execute_message(const char *portal_name, long max_rows) | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * Report query to various monitoring facilities. | ||||
| 	 */ | ||||
| 	debug_query_string = "execute message"; | ||||
| 
 | ||||
| 	pgstat_report_activity(portal->sourceText ? portal->sourceText : "<EXECUTE>"); | ||||
| 
 | ||||
| 	set_ps_display(portal->commandTag, false); | ||||
| 
 | ||||
| 	if (save_log_statement_stats) | ||||
| 		ResetUsage(); | ||||
| 
 | ||||
| 	/* Does the portal contain a transaction command? */ | ||||
| 	is_xact_command = IsTransactionStmtList(portal->parseTrees); | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * If we re-issue an Execute protocol request against an existing portal, | ||||
| 	 * then we are only fetching more rows rather than completely re-executing | ||||
| 	 * the query from the start. atStart is never reset for a v3 portal, so we | ||||
| 	 * are safe to use this check. | ||||
| 	 */ | ||||
| 	execute_is_fetch = !portal->atStart; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * We must copy the sourceText and prepStmtName into MessageContext in | ||||
| 	 * case the portal is destroyed during finish_xact_command. Can avoid the | ||||
| @ -1710,7 +1690,7 @@ exec_execute_message(const char *portal_name, long max_rows) | ||||
| 	 */ | ||||
| 	if (is_xact_command) | ||||
| 	{ | ||||
| 		sourceText = pstrdup(portal->sourceText); | ||||
| 		sourceText = portal->sourceText ? pstrdup(portal->sourceText) : NULL; | ||||
| 		if (portal->prepStmtName) | ||||
| 			prepStmtName = pstrdup(portal->prepStmtName); | ||||
| 		else | ||||
| @ -1732,6 +1712,18 @@ exec_execute_message(const char *portal_name, long max_rows) | ||||
| 		portalParams = portal->portalParams; | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * Report query to various monitoring facilities. | ||||
| 	 */ | ||||
| 	debug_query_string = sourceText ? sourceText : "<EXECUTE>"; | ||||
| 
 | ||||
| 	pgstat_report_activity(debug_query_string); | ||||
| 
 | ||||
| 	set_ps_display(portal->commandTag, false); | ||||
| 
 | ||||
| 	if (save_log_statement_stats) | ||||
| 		ResetUsage(); | ||||
| 
 | ||||
| 	BeginCommand(portal->commandTag, dest); | ||||
| 
 | ||||
| 	/*
 | ||||
| @ -1746,6 +1738,14 @@ exec_execute_message(const char *portal_name, long max_rows) | ||||
| 	 */ | ||||
| 	start_xact_command(); | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * If we re-issue an Execute protocol request against an existing portal, | ||||
| 	 * then we are only fetching more rows rather than completely re-executing | ||||
| 	 * the query from the start. atStart is never reset for a v3 portal, so we | ||||
| 	 * are safe to use this check. | ||||
| 	 */ | ||||
| 	execute_is_fetch = !portal->atStart; | ||||
| 
 | ||||
| 	/* Log immediately if dictated by log_statement */ | ||||
| 	if (check_log_statement_cooked(portal->parseTrees)) | ||||
| 	{ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user