@@ -181,7 +181,7 @@ get_stmt_profile_next(profiler_iterator *pi)
181
181
HASH_FIND ,
182
182
& found );
183
183
184
- if (found )
184
+ if (! found )
185
185
elog (ERROR , "broken consistency of plpgsql_check profiler chunks" );
186
186
187
187
pi -> current_statement = 0 ;
@@ -820,14 +820,14 @@ update_persistent_profile(profiler_info *pinfo, PLpgSQL_function *func)
820
820
else
821
821
stmt_counter = -1 ;
822
822
823
+ hk .chunk_num = 0 ;
824
+
823
825
/* we should to enter empty chunks first */
824
826
for (i = 0 ; i < profile -> nstatements ; i ++ )
825
827
{
826
828
profiler_stmt_reduced * prstmt ;
827
829
profiler_stmt * pstmt = & pinfo -> stmts [i ];
828
830
829
- hk .chunk_num = 0 ;
830
-
831
831
if (stmt_counter == -1 || stmt_counter >= STATEMENTS_PER_CHUNK )
832
832
{
833
833
hk .chunk_num += 1 ;
@@ -944,17 +944,17 @@ profiler_update_map(profiler_profile *profile, PLpgSQL_stmt *stmt)
944
944
int i ;
945
945
946
946
/* calculate new size of map */
947
- for (lines = profile -> stmts_map_max_lineno ; stmt -> lineno < lines ;)
947
+ for (lines = profile -> stmts_map_max_lineno ; lineno > lines ;)
948
948
if (lines < 10000 )
949
949
lines *= 2 ;
950
950
else
951
951
lines += 10000 ;
952
952
953
- profile -> stmts_map = realloc (profile -> stmts_map ,
953
+ profile -> stmts_map = repalloc (profile -> stmts_map ,
954
954
lines * sizeof (profiler_map_entry ));
955
955
956
956
for (i = profile -> stmts_map_max_lineno ; i < lines ; i ++ )
957
- profile -> stmts_map [i ]. stmt = NULL ;
957
+ memset ( & profile -> stmts_map [i ], 0 , sizeof ( profiler_map_entry )) ;
958
958
959
959
profile -> stmts_map_max_lineno = lines ;
960
960
}
0 commit comments