/* * cursor_fixup_vobjs () - * return: NO_ERROR on all ok, ER status( or ER_FAILED) otherwise * value(in/out): a db_value * Note: if value is an OID then turn it into an OBJECT type value * if value is a VOBJ then turn it into a vmop * if value is a set/seq then do same fixups on its elements */ static int cursor_fixup_vobjs (DB_VALUE * value_p) { DB_OBJECT *obj; int rc; switch (DB_VALUE_DOMAIN_TYPE (value_p)) { case DB_TYPE_OID: rc = vid_oid_to_object (value_p, &obj); DB_MAKE_OBJECT (value_p, obj); break; case DB_TYPE_VOBJ: if (DB_IS_NULL (value_p)) { db_value_clear (value_p); db_value_domain_init (value_p, DB_TYPE_OBJECT, DB_DEFAULT_PRECISION, DB_DEFAULT_SCALE); rc = NO_ERROR; } else { rc = vid_vobj_to_object (value_p, &obj); pr_clear_value (value_p); DB_MAKE_OBJECT (value_p, obj); } break; case DB_TYPE_SET: case DB_TYPE_MULTISET: case DB_TYPE_SEQUENCE: /* fixup any set/seq of vobjs into a set/seq of vmops */ rc = cursor_fixup_set_vobjs (value_p); break; default: rc = NO_ERROR; break; } return rc; }
int main (int argc, char *argv[]) { float disk_compat_level = 0.0f; char *prog_name; const char *qp1 = "select db_user, password.password from db_user"; DB_VALUE user_val, password_val; MOP user_class; MOP user; char *db_name; char *password; char *decoded_str; char *encoded_str; int retval, error; DB_QUERY_RESULT *query_result; DB_QUERY_ERROR query_error; char out_buf[128]; if (argc < 2) { printf ("usage : %s databasename\n", argv[0]); return 1; } prog_name = argv[0]; db_name = argv[1]; AU_DISABLE_PASSWORDS (); db_set_client_type (DB_CLIENT_TYPE_ADMIN_UTILITY); db_login ("dba", NULL); db_restart (prog_name, 0, db_name); error = db_execute (qp1, &query_result, &query_error); if (error > 0) { error = db_query_first_tuple (query_result); while (error == NO_ERROR) { retval = db_query_get_tuple_value (query_result, 0, &user_val); if (retval != NO_ERROR) { printf ("%s\n", db_error_string (1)); return 1; } retval = db_query_get_tuple_value (query_result, 1, &password_val); if (retval != NO_ERROR) { printf ("%s\n", db_error_string (1)); return 1; } if (DB_IS_NULL (&user_val) || DB_IS_NULL (&password_val)) { error = db_query_next_tuple (query_result); continue; } user = db_get_object (&user_val); password = db_get_string (&password_val); retval = io_relseek_old (password, 1, out_buf); if (retval != NO_ERROR) { printf ("%s\n", db_error_string (1)); return 1; } retval = au_set_password (user, out_buf); if (retval != NO_ERROR) { printf ("%s\n", db_error_string (1)); return 1; } error = db_query_next_tuple (query_result); } db_query_end (query_result); } db_commit_transaction (); db_shutdown (); return 0; }