idleInTrans.911.patch

application/octet-stream

Filename: idleInTrans.911.patch
Type: application/octet-stream
Part: 0
Message: IDLE in transaction introspection

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
../postgresql-9.1.1wip/src/backend/postmaster/pgstat.c 25 5
*** src/backend/postmaster/pgstat.c	2011-09-22 17:57:57.000000000 -0400
--- ../postgresql-9.1.1wip/src/backend/postmaster/pgstat.c	2011-10-31 17:17:47.000000000 -0400
***************
*** 2486,2493 ****
  	 */
  	start_timestamp = GetCurrentStatementStartTimestamp();
  
! 	len = strlen(cmd_str);
! 	len = pg_mbcliplen(cmd_str, len, pgstat_track_activity_query_size - 1);
  
  	/*
  	 * Update my status entry, following the protocol of bumping
--- 2486,2493 ----
  	 */
  	start_timestamp = GetCurrentStatementStartTimestamp();
  
!     len = strlen(cmd_str);
!     len = pg_mbcliplen(cmd_str, len, pgstat_track_activity_query_size - 1);
  
  	/*
  	 * Update my status entry, following the protocol of bumping
***************
*** 2495,2504 ****
  	 * ensure the compiler doesn't try to get cute.
  	 */
  	beentry->st_changecount++;
  
! 	beentry->st_activity_start_timestamp = start_timestamp;
! 	memcpy((char *) beentry->st_activity, cmd_str, len);
! 	beentry->st_activity[len] = '\0';
  
  	beentry->st_changecount++;
  	Assert((beentry->st_changecount & 1) == 0);
--- 2495,2524 ----
  	 * ensure the compiler doesn't try to get cute.
  	 */
  	beentry->st_changecount++;
+     beentry->st_activity_start_timestamp = start_timestamp;
  
!     if ( memcmp(cmd_str,"<IDLE> i",8) == 0)
!     {
!         char        *tString;
!         tString = pnstrdup("<IDLE> in transaction\n: Previous: ",34);
!         len = strlen(tString);
!         len = snprintf (tString,
!                         len + 
!                         pg_mbcliplen(beentry->st_activity,
!                                       strlen(beentry->st_activity),
!                                        pgstat_track_activity_query_size -1 ),
!                         "%s%s",tString,beentry->st_activity);
!         memcpy((char *) beentry->st_activity, tString, len);
!         beentry->st_activity[len] = '\0';
!         pfree((char*) tString);
!     
!     }   
!     else
!     {
! 
!         memcpy((char *) beentry->st_activity, cmd_str, len);
!         beentry->st_activity[len] = '\0';
!     }
  
  	beentry->st_changecount++;
  	Assert((beentry->st_changecount & 1) == 0);