@@ -77,7 +77,7 @@ int Lock_create(struct agmdb_lock *new_lock, const char* lock_name, int lock_nam
7777if (new_mutex ==NULL )
7878return AGMDB_ERROR_LOCK_WIN_MUTEX_CREATE_FAIL;
7979if ((GetLastError () == ERROR_ALREADY_EXISTS) != lock_exists)// One lock exists, another not.
80- return AGMDB_ERROR_LOCK_WIN_ONLY_ONE_LCOK_EXISTS ;
80+ return AGMDB_ERROR_LOCK_WIN_ONLY_ONE_LOCK_EXISTS ;
8181 new_lock->write_lock_handle =OpenMutex (
8282 MUTEX_ALL_ACCESS,//
8383false ,//
@@ -901,7 +901,7 @@ int AGMDB_setExpireTime(struct agmdb_handler *dbm, unsigned int expire_time){
901901return AGMDB_ERROR_HANDLE_NULL;
902902
903903if (expire_time <0 )
904- return AGMDB_ERROR_SET_NAGATIVE_EXIPRE_TIME ;
904+ return AGMDB_ERROR_SET_NEGATIVE_EXIPRE_TIME ;
905905 *SHM_EXPIRE_TIME ((const PTR_VOID)(dbm->shm_base )) = expire_time;
906906return AGMDB_SUCCESS;
907907}
@@ -1077,15 +1077,121 @@ int AGMDB_removeStale(struct agmdb_handler *dbm) {
10771077return AGMDB_SUCCESS;
10781078}
10791079
1080- const char *AGMDB_getErrorInfo (int error_code){
1081- return NULL ;
1082- }
10831080/* *
10841081 **========================================================
10851082 ** AG Memory Database Debug API
10861083 **========================================================
10871084*/
10881085
1086+ /* *
1087+ ** Get the detail information of an error.
1088+ ** @param error_no: the error code returned by a function.
1089+ ** return: The error information.
1090+ */
1091+ const char *AGMDB_getErrorInfo (int error_no){
1092+ switch (error_no){
1093+ case AGMDB_SUCCESS:
1094+ return " Success!" ;
1095+ case AGMDB_ERROR_LOCK_OP_NEGATIVE_VAL:
1096+ return " When operating the lock, the operation value is negative!" ;
1097+
1098+ case AGMDB_ERROR_LOCK_LINUX_SEM_CREATE_FAIL:
1099+ return " In Linux system, failed when creating the semaphore. Please check the semaphore limit of the system." ;
1100+ case AGMDB_ERROR_LOCK_LINUX_SEM_OPEN_FAIL:
1101+ return " In Linux system, failed when opening an existed semaphore. Please check the semaphore limit and permission settings." ;
1102+ case AGMDB_ERROR_LOCK_LINUX_SEM_INIT_FAIL:
1103+ return " In Linux system, failed when initializing the semaphore value. Please check the existence and permission of the semaphore." ;
1104+ case AGMDB_ERROR_LOCK_LINUX_SEM_MODIFY_FAIL:
1105+ return " In Linux system, failed when modifying the semaphore value. Please check the existence and permission of the semaphore." ;
1106+
1107+ case AGMDB_ERROR_LOCK_WIN_NAME_INVALID_STRING:
1108+ return " In Windows system, the name of lock is not a valid string. Please check the data_dir setting in configuration file." ;
1109+ case AGMDB_ERROR_LOCK_WIN_MUTEX_CREATE_FAIL:
1110+ return " In Windows system, failed when creating the mutex object." ;
1111+ case AGMDB_ERROR_LOCK_WIN_ONLY_ONE_LOCK_EXISTS:
1112+ return " In Windows system, one and only one lock has existed." ;
1113+ case AGMDB_ERROR_LOCK_WIN_GET_MUTEX_FAIL:
1114+ return " In Windows system, failed when getting the mutex object. Possible reason is deadlock or permission issue." ;
1115+ case AGMDB_ERROR_LOCK_WIN_RELEASE_MUTEX_FAIL:
1116+ return " In Windows system, failed when releasing the mutex object." ;
1117+
1118+ case AGMDB_ERROR_SHM_BASE_NULL:
1119+ return " The shared memory base address is NULL. Please check the agmdb_handler object." ;
1120+ case AGMDB_ERROR_SHM_SIZE_TOO_SMALL:
1121+ return " The size setting of shared memory is too small to save the DB control information." ;
1122+ case AGMDB_ERROR_SHM_NAME_INVALID_STRING:
1123+ return " The name of database is not a valid string. Please check the data_dir setting in configuration file." ;
1124+ case AGMDB_ERROR_SHM_ENTRY_NUM_NEGATIVE:
1125+ return " The setting of DB's entry number is negative!" ;
1126+
1127+ case AGMDB_ERROR_SHM_LINUX_CREATE_FAIL:
1128+ return " In Linux system, failed when creating the shared memory." ;
1129+ case AGMDB_ERROR_SHM_LINUX_MAP_FAIL:
1130+ return " In Linux system, failed when mapping the shared memory into the process's address space." ;
1131+
1132+ case AGMDB_ERROR_SHM_WIN_CREATE_FAIL:
1133+ return " In Windows system, failed when creating the shared memory." ;
1134+ case AGMDB_ERROR_SHM_WIN_MAP_FAIL:
1135+ return " In Windows system, failed when mapping the shared memory into the process's address space." ;
1136+
1137+ case AGMDB_ERROR_INSERT_INVALID_ENTRY_INTO_SPARELIST:
1138+ return " The AGMDB is inserting an invalid entry into the spare list." ;
1139+ case AGMDB_ERROR_INSERT_BUSY_ENTRY_INTO_SPARELIST:
1140+ return " The AGMDB is inserting a busy entry into the spare list. Should remove the entry from hashlist first." ;
1141+
1142+ case AGMDB_ERROR_INSERT_INVALID_ENTRY_INTO_HASHLIST:
1143+ return " The AGMDB is inserting an invalid entry into the hashlist." ;
1144+ case AGMDB_ERROR_INSERT_BUSY_ENTRY_INTO_HASHLIST:
1145+ return " The AGMDB is inserting a busy entry into the hashlist." ;
1146+
1147+ case AGMDB_ERROR_REMOVE_INVALID_ENTRY_FROM_HASHLIST:
1148+ return " The AGMDB is removing an invalid entry from hashlist" ;
1149+ case AGMDB_ERROR_NONHEAD_ENTRY_IN_HASHLIST_WITHOUT_PREV:
1150+ return " An entry in hashlist without previous entry is not the head of the hashlist." ;
1151+
1152+ case AGMDB_ERROR_INSERT_INVALID_ENTRY_INTO_TIMELIST:
1153+ return " The AGMDB is inserting an invalid entry into the expire time list." ;
1154+ case AGMDB_ERROR_REMOVE_INVALID_ENTRY_FROM_TIMELIST:
1155+ return " The AGMDB is removing an invalid entry into the expire time list." ;
1156+
1157+ case AGMDB_ERROR_SET_KEYVAL_OF_INVALID_ENTRY:
1158+ return " The AGMDB is setting key-value to an invalid entry." ;
1159+
1160+ case AGMDB_ERROR_KEY_INVALID_STRING:
1161+ return " The key is not a valid string." ;
1162+ case AGMDB_ERROR_KEY_TOO_LONG:
1163+ return " The key string is too long." ;
1164+ case AGMDB_ERROR_VALUE_INVALID_STRING:
1165+ return " The value is not a valid string." ;
1166+ case AGMDB_ERROR_VALUE_TOO_LONG:
1167+ return " The value string is too long." ;
1168+
1169+ case AGMDB_ERROR_HANDLE_NULL:
1170+ return " The agmdb_handler is NULL." ;
1171+ case AGMDB_ERROR_DELETE_INVALID_ENTRY:
1172+ return " The AGMDB is deleting an invalid entry." ;
1173+ case AGMDB_ERROR_NAME_NULL:
1174+ return " The name of AGMDB is NULL" ;
1175+ case AGMDB_ERROR_NAME_INVALID_STRING:
1176+ return " The name of AGMDB is not a valid string." ;
1177+
1178+ case AGMDB_ERROR_SET_NEGATIVE_EXIPRE_TIME:
1179+ return " Set the expire time to a negative value." ;
1180+
1181+ case AGMDB_ERROR_GET_BUFFER_NULL:
1182+ return " In get function, the buffer is NULL." ;
1183+ case AGMDB_ERROR_GET_INVALID_BUFFER_LEN:
1184+ return " In get function, the length of buffer is an invalid number." ;
1185+ case AGMDB_ERROR_GET_BUFFER_TOO_SMALL:
1186+ return " In get function, the buffer is too small to save the data." ;
1187+
1188+ case AGMDB_ERROR_TIMELIST_LONG_NOTEQUEAL_SHM_CNT:
1189+ return " The size of expire time list does not equal to the entry counter in DB control block." ;
1190+ case AGMDB_ERROR_GETALL_ARRAY_TOO_SMALL:
1191+ return " In getAll function, the array is too samll to save the data." ;
1192+ }
1193+ }
1194+
10891195/* *
10901196 ** Get the number of keys in a database.
10911197 ** You have to get SHARED or EXCLUSIVE LOCK of the database before calling this function.