@@ -1109,13 +1109,24 @@ void hsetnxCommand(client *c) {
11091109void hsetCommand (client * c ) {
11101110 int i , created = 0 ;
11111111 robj * o ;
1112+ long previous_element_number ;
1113+ long current_element_number ;
11121114
11131115 if ((c -> argc % 2 ) == 1 ) {
11141116 addReplyErrorArity (c );
11151117 return ;
11161118 }
11171119
1118- if ((o = hashTypeLookupWriteOrCreate (c , c -> argv [1 ])) == NULL ) return ;
1120+ o = lookupKeyWrite (c -> db , c -> argv [1 ]);
1121+ if (checkType (c , o , OBJ_HASH )) return ;
1122+ if (o == NULL ) {
1123+ o = createHashObject ();
1124+ dbAdd (c -> db , c -> argv [1 ], & o );
1125+ previous_element_number = 0 ;
1126+ } else {
1127+ previous_element_number = hashTypeLength (o );
1128+ }
1129+
11191130 hashTypeTryConversion (o , c -> argv , 2 , c -> argc - 1 );
11201131 bool has_volatile_fields = hashTypeHasVolatileFields (o );
11211132 for (i = 2 ; i < c -> argc ; i += 2 ) {
@@ -1128,6 +1139,11 @@ void hsetCommand(client *c) {
11281139 notifyKeyspaceEvent (NOTIFY_HASH , "hset" , c -> argv [1 ], c -> db -> id );
11291140 server .dirty += (c -> argc - 2 ) / 2 ;
11301141
1142+ if (created > 0 ) {
1143+ current_element_number = previous_element_number + created ;
1144+ updateBigKeyList (c -> argv [1 ], previous_element_number , current_element_number , HASH_TYPE );
1145+ }
1146+
11311147 /* HMSET (deprecated) and HSET return value is different. */
11321148 char * cmdname = c -> argv [0 ]-> ptr ;
11331149 if (cmdname [1 ] == 's' || cmdname [1 ] == 'S' ) {
0 commit comments