@@ -1143,21 +1143,21 @@ BOOL exmdb_server::set_pgm_id(const char *dir, uint64_t message_id, uint32_t map
11431143
11441144/* if count of indices and ungroup_proptags are both 0 means full change */
11451145BOOL exmdb_server::save_change_indices (const char *dir, uint64_t message_id,
1146- uint64_t cn, const INDEX_ARRAY *pindices ,
1147- const PROPTAG_ARRAY *pungroup_proptags ) try
1146+ uint64_t cn, const std::vector< uint32_t > &groups ,
1147+ const std::vector< proptag_t > &ugrp_tags ) try
11481148{
11491149 EXT_PUSH ext_push;
11501150 char sql_string[128 ];
11511151 static constexpr size_t idbuff_size = 0x8000 ;
1152- auto indices_buff = std::make_unique<uint8_t []>(idbuff_size);
1153- auto proptags_buff = std::make_unique<uint8_t []>(idbuff_size);
1152+ auto grp_buf = std::make_unique<uint8_t []>(idbuff_size);
1153+ auto utag_buf = std::make_unique<uint8_t []>(idbuff_size);
11541154
11551155 auto pdb = db_engine_get_db (dir);
11561156 if (!pdb)
11571157 return FALSE ;
11581158 /* Only one SQL operation, no transaction needed. */
11591159 auto mid_val = rop_util_get_gc_value (message_id);
1160- if (0 == pindices-> count && 0 == pungroup_proptags-> count ) {
1160+ if (groups. empty () && ugrp_tags. empty () ) {
11611161 snprintf (sql_string, std::size (sql_string), " UPDATE messages SET "
11621162 " group_id=? WHERE message_id=%llu" , LLU{mid_val});
11631163 auto pstmt = pdb->prep (sql_string);
@@ -1172,12 +1172,12 @@ BOOL exmdb_server::save_change_indices(const char *dir, uint64_t message_id,
11721172 return FALSE ;
11731173 sqlite3_bind_int64 (pstmt, 1 , mid_val);
11741174 sqlite3_bind_int64 (pstmt, 2 , rop_util_get_gc_value (cn));
1175- if (!ext_push.init (indices_buff .get (), idbuff_size, 0 ) ||
1176- ext_push.p_proptag_a (*pindices ) != pack_result::ok)
1175+ if (!ext_push.init (grp_buf .get (), idbuff_size, 0 ) ||
1176+ ext_push.p_proptag_a (groups ) != pack_result::ok)
11771177 return false ;
11781178 sqlite3_bind_blob (pstmt, 3 , ext_push.m_udata , ext_push.m_offset , SQLITE_STATIC);
1179- if (!ext_push.init (proptags_buff .get (), idbuff_size, 0 ) ||
1180- ext_push.p_proptag_a (*pungroup_proptags ) != pack_result::ok)
1179+ if (!ext_push.init (utag_buf .get (), idbuff_size, 0 ) ||
1180+ ext_push.p_proptag_a (ugrp_tags ) != pack_result::ok)
11811181 return false ;
11821182 sqlite3_bind_blob (pstmt, 4 , ext_push.m_udata , ext_push.m_offset , SQLITE_STATIC);
11831183 return pstmt.step () == SQLITE_DONE ? TRUE : false ;
@@ -1187,81 +1187,45 @@ BOOL exmdb_server::save_change_indices(const char *dir, uint64_t message_id,
11871187}
11881188
11891189/* if count of indices and ungroup_proptags are both 0 means full change */
1190- BOOL exmdb_server::get_change_indices (const char *dir,
1191- uint64_t message_id, uint64_t cn, INDEX_ARRAY *pindices ,
1192- PROPTAG_ARRAY *pungroup_proptags )
1190+ BOOL exmdb_server::get_change_indices (const char *dir, uint64_t message_id,
1191+ uint64_t cn, std::vector< uint32_t > *groups ,
1192+ std::vector<gromox:: proptag_t > *ugrp_tags )
11931193{
11941194 EXT_PULL ext_pull;
1195- INDEX_ARRAY tmp_indices;
1196- PROPTAG_ARRAY tmp_proptags;
11971195
11981196 auto cn_val = rop_util_get_gc_value (cn);
11991197 auto pdb = db_engine_get_db (dir);
12001198 if (!pdb)
12011199 return FALSE ;
12021200 /* Only one SQL operation, no transaction needed. */
12031201 auto mid_val = rop_util_get_gc_value (message_id);
1204- std::unique_ptr<INDEX_ARRAY, pta_delete> ptmp_indices (proptag_array_init ());
1205- if (ptmp_indices == nullptr )
1206- return FALSE ;
1207- std::unique_ptr<PROPTAG_ARRAY, pta_delete> ptmp_proptags (proptag_array_init ());
1208- if (ptmp_proptags == nullptr )
1209- return FALSE ;
12101202 char sql_string[128 ];
12111203 snprintf (sql_string, std::size (sql_string), " SELECT change_number,"
12121204 " indices, proptags FROM message_changes"
12131205 " WHERE message_id=%llu" , LLU{mid_val});
12141206 auto pstmt = pdb->prep (sql_string);
12151207 if (pstmt == nullptr )
12161208 return FALSE ;
1209+ groups->clear ();
1210+ ugrp_tags->clear ();
12171211 while (pstmt.step () == SQLITE_ROW) {
12181212 if (gx_sql_col_uint64 (pstmt, 0 ) <= cn_val)
12191213 continue ;
12201214 if (sqlite3_column_bytes (pstmt, 1 ) > 0 ) {
12211215 ext_pull.init (sqlite3_column_blob (pstmt, 1 ),
12221216 sqlite3_column_bytes (pstmt, 1 ),
12231217 common_util_alloc, 0 );
1224- if (ext_pull.g_proptag_a (&tmp_indices ) != pack_result::ok)
1218+ if (ext_pull.g_proptag_a (groups ) != pack_result::ok)
12251219 return FALSE ;
1226- for (unsigned int i = 0 ; i < tmp_indices.count ; ++i)
1227- if (!proptag_array_append (ptmp_indices.get (),
1228- tmp_indices.pproptag [i]))
1229- return FALSE ;
12301220 }
12311221 if (sqlite3_column_bytes (pstmt, 2 ) > 0 ) {
12321222 ext_pull.init (sqlite3_column_blob (pstmt, 2 ),
12331223 sqlite3_column_bytes (pstmt, 2 ),
12341224 common_util_alloc, 0 );
1235- if (ext_pull.g_proptag_a (&tmp_proptags ) != pack_result::ok)
1225+ if (ext_pull.g_proptag_a (ugrp_tags ) != pack_result::ok)
12361226 return FALSE ;
1237- for (unsigned int i = 0 ; i < tmp_proptags.count ; ++i)
1238- if (!proptag_array_append (ptmp_proptags.get (),
1239- tmp_proptags.pproptag [i]))
1240- return FALSE ;
12411227 }
12421228 }
1243- pstmt.finalize ();
1244- pdb.reset ();
1245- pindices->count = ptmp_indices->count ;
1246- if (ptmp_indices->count > 0 ) {
1247- pindices->pproptag = cu_alloc<uint32_t >(ptmp_indices->count );
1248- if (pindices->pproptag == nullptr )
1249- return FALSE ;
1250- memcpy (pindices->pproptag , ptmp_indices->pproptag ,
1251- sizeof (uint32_t )*ptmp_indices->count );
1252- }
1253- ptmp_indices.reset ();
1254- if (ptmp_proptags->count == 0 ) {
1255- pungroup_proptags->count = 0 ;
1256- pungroup_proptags->pproptag = NULL ;
1257- return TRUE ;
1258- }
1259- pungroup_proptags->count = ptmp_proptags->count ;
1260- pungroup_proptags->pproptag = cu_alloc<uint32_t >(ptmp_proptags->count );
1261- if (pungroup_proptags->pproptag == nullptr )
1262- return FALSE ;
1263- memcpy (pungroup_proptags->pproptag , ptmp_proptags->pproptag ,
1264- sizeof (uint32_t )*ptmp_proptags->count );
12651229 return TRUE ;
12661230}
12671231
0 commit comments