/** * Removes (drops) a secondary index. * * @param as The aerospike cluster to connect to. * @param err The error is populated if the return value is not AEROSPIKE_OK. * @param policy The policy to use for this operation. If NULL, then the default policy will be used. * @param ns The namespace of the index to be removed * @param name The name of the index to be removed * * @return AEROSPIKE_OK if successful. Otherwise an error. */ as_status aerospike_index_remove( aerospike * as, as_error * err, const as_policy_info * policy, const char * ns, const char * name) { as_error_reset(err); char * response = NULL; int rc = citrusleaf_secondary_index_drop(as->cluster, ns, name, &response); if ( response != NULL ) { free(response); } return as_error_fromrc(err, rc); }
/** * Removes (drops) a secondary index. * * ~~~~~~~~~~{.c} * if ( aerospike_index_remove(&as, &err, NULL, "test", idx_test_demo_bin1") != AEROSPIKE_OK ) { * fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line); * } * ~~~~~~~~~~ * * @param as The aerospike instance to use for this operation. * @param err The as_error to be populated if an error occurs. * @param policy The policy to use for this operation. If NULL, then the default policy will be used. * @param ns The namespace containing the index to be removed. * @param name The name of the index to be removed. * * @return AEROSPIKE_OK if successful or index does not exist. Otherwise an error. * * @ingroup index_operations */ as_status aerospike_index_remove( aerospike * as, as_error * err, const as_policy_info * policy, const char * ns, const char * name) { as_error_reset(err); char * response = NULL; int rc = citrusleaf_secondary_index_drop(as->cluster, ns, name, &response); switch (rc) { case CITRUSLEAF_OK: case CITRUSLEAF_FAIL_INDEX_NOTFOUND: break; default: as_strncpy(err->message, response, sizeof(err->message)); as_error_fromrc(err, rc); break; } free(response); return err->code; }