@@ -54,9 +54,6 @@ PG_MODULE_MAGIC;
5454
5555#define PGUNSIXBIT (val ) (((val) & 0x3F) + '0')
5656
57- #define _snprintf (_str_dst , _str_src , _len , _max_len )\
58- memcpy((void *)_str_dst, _str_src, _len < _max_len ? _len : _max_len)
59-
6057#define pgsm_enabled (level ) \
6158 (!IsParallelWorker() && \
6259 (pgsm_track == PGSM_TRACK_ALL || \
@@ -1281,8 +1278,6 @@ pgsm_update_entry(pgsmEntry *entry,
12811278{
12821279 int index ;
12831280 double old_mean ;
1284- int message_len = error_info ? strlen (error_info -> message ) : 0 ;
1285- int sqlcode_len = error_info ? strlen (error_info -> sqlcode ) : 0 ;
12861281 int plan_text_len = plan_info ? plan_info -> plan_len : 0 ;
12871282
12881283 /*
@@ -1305,7 +1300,7 @@ pgsm_update_entry(pgsmEntry *entry,
13051300 */
13061301 if (pgsm_extract_comments && kind == PGSM_STORE
13071302 && !entry -> counters .info .comments [0 ] && comments_len > 0 )
1308- _snprintf (entry -> counters .info .comments , comments , comments_len + 1 , COMMENTS_LEN );
1303+ strlcpy (entry -> counters .info .comments , comments , COMMENTS_LEN );
13091304
13101305 if (kind == PGSM_PLAN || kind == PGSM_STORE )
13111306 {
@@ -1375,14 +1370,14 @@ pgsm_update_entry(pgsmEntry *entry,
13751370 {
13761371 entry -> counters .planinfo .planid = plan_info -> planid ;
13771372 entry -> counters .planinfo .plan_len = plan_text_len ;
1378- _snprintf (entry -> counters .planinfo .plan_text , plan_info -> plan_text , plan_text_len + 1 , PLAN_TEXT_LEN );
1373+ strlcpy (entry -> counters .planinfo .plan_text , plan_info -> plan_text , PLAN_TEXT_LEN );
13791374 }
13801375
13811376 /* Only should process this once when storing the data */
13821377 if (kind == PGSM_STORE )
13831378 {
13841379 if (pgsm_track_application_names && app_name_len > 0 && !entry -> counters .info .application_name [0 ])
1385- _snprintf (entry -> counters .info .application_name , app_name , app_name_len + 1 , APPLICATIONNAME_LEN );
1380+ strlcpy (entry -> counters .info .application_name , app_name , APPLICATIONNAME_LEN );
13861381
13871382 entry -> counters .info .num_relations = num_relations ;
13881383 for (int i = 0 ; i < num_relations ; i ++ )
@@ -1428,8 +1423,8 @@ pgsm_update_entry(pgsmEntry *entry,
14281423 if (error_info )
14291424 {
14301425 entry -> counters .error .elevel = error_info -> elevel ;
1431- _snprintf (entry -> counters .error .sqlcode , error_info -> sqlcode , sqlcode_len , SQLCODE_LEN );
1432- _snprintf (entry -> counters .error .message , error_info -> message , message_len , ERROR_MESSAGE_LEN );
1426+ strlcpy (entry -> counters .error .sqlcode , error_info -> sqlcode , SQLCODE_LEN );
1427+ strlcpy (entry -> counters .error .message , error_info -> message , ERROR_MESSAGE_LEN );
14331428 }
14341429
14351430 entry -> counters .calls .rows += rows ;
0 commit comments