/* * add_method_internal() - This is internal work function to add a method * definition. * return : error code * class(in) : class or instance * name(in): method name * implementation(in): implementation function name * namespace(in): attribute or class namespace identifier */ static int add_method_internal (MOP class_, const char *name, const char *implementation, SM_NAME_SPACE name_space) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_2ARGS_RETURN_EXPR (class_, name, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_add_method_any (def, name, implementation, name_space); if (error) { smt_quit (def); } else { error = sm_update_class_auto (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * db_set_loader_commands() - This function sets the dynamic linking loader * command string for a class. This is usually a list of library names that * are to be included when linking the methods for a particular class. * return : error code * class(in): class or instance * commands(in): link command string * * note : The format of this string must be suitable for insertion in the * command line of the UNIX ld command (link editor), such as * "-L /usr/local/lib -l utilities" */ int db_set_loader_commands (MOP class_, const char *commands) { int error = NO_ERROR; SM_TEMPLATE *def; CHECK_CONNECT_ERROR (); CHECK_1ARG_ERROR (class_); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_set_loader_commands (def, commands); if (error) { smt_quit (def); } else { error = sm_update_class (def, NULL); if (error) { smt_quit (def); } } } return (error); }
/* * db_drop_constraint() - This function is used remove constraint from a class. * Please refer to the header information for db_add_constraint() for basic * information on classes and constraints. * return : error code * classmop: class (or instance) pointer * constraint_type: type of constraint to drop * constraint_name: constraint name * att_names: names of attributes to be constrained * class_attributes: flag indicating class attribute status * (0 if this is not a class attribute, * non-zero if this is a class attribute) * * note : * If the name is known, the constraint can be dropped by name, in which * case the <att_names> parameter should be NULL. * If the name is not known, the constraint can be specified by the * combination of class pointer and attribute names. * The order of the attribute names must match the order given when the * constraint was added. In this case, the <constraint_name> should be NULL. */ int db_drop_constraint (MOP classmop, DB_CONSTRAINT_TYPE constraint_type, const char *constraint_name, const char **att_names, int class_attributes) { int retval; char *name = NULL; CHECK_CONNECT_ERROR (); CHECK_1ARG_ERROR (classmop); CHECK_MODIFICATION_ERROR (); name = sm_produce_constraint_name_mop (classmop, constraint_type, att_names, NULL, constraint_name); if (name == NULL) { assert (er_errid () != NO_ERROR); retval = er_errid (); } else { retval = sm_drop_constraint (classmop, constraint_type, name, att_names, class_attributes ? true : false, false); free_and_init (name); } return (retval); }
/* * db_change_default() - This function changes the default value definition of * an attribute. Default values are normally established when the attribute * is first defined using the db_add_attribute() function. This function * can be used to change the default value after the attribute has been * defined. * return : error code * class(in): class or instance pointer * name(in) : attribute name * value(in): value container with value * * note: Do not use this function to change the values of class attributes. * Instead, the db_put() function is used with the class object as the * first argument. */ int db_change_default (MOP class_, const char *name, DB_VALUE * value) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_3ARGS_RETURN_EXPR (class_, name, value, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_set_attribute_default (def, name, false, value, DB_DEFAULT_NONE); if (error) { smt_quit (def); } else { error = sm_update_class (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * db_rename_internal() - This will rename any of the various class components: * attributes, class attributes, methods, class methods. * return : error code * class(in) : class to alter * name(in) : component name * class_namespace(in): class namespace flag * newname(in) : new component name */ int db_rename_internal (MOP class_, const char *name, int class_namespace, const char *newname) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_rename_any (def, name, class_namespace, newname); if (error) { smt_quit (def); } else { error = sm_update_class_auto (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * disk_reserve_instance - This is used to reserve space for an instance that * was referenced in the load file but has not yet been defined. * return: NO_ERROR if successful, error code otherwise * classop(in): class * oid(in): returned instance OID */ int disk_reserve_instance (MOP classop, OID * oid) { int error = NO_ERROR; SM_CLASS *class_; HFID *hfid; int expected; class_ = (SM_CLASS *) locator_fetch_class (classop, DB_FETCH_READ); if (class_ == NULL) { error = er_errid (); } else { expected = estimate_object_size (class_); hfid = get_class_heap (classop, class_); if (hfid == NULL) { error = er_errid (); } else { if (heap_assign_address_with_class_oid (NULL, hfid, oid, expected, ws_oid (classop)) != NO_ERROR) { error = ER_LDR_CANT_INSERT; er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 0); } } } return error; }
/* * db_change_method_implementation() - This function changes the name of C * function that is called when the method is invoked. * returns/side-effects: error code * class(in) : class or instance * name(in) : method name * class_method(in): class method flag * newname(in) : new interface function name */ int db_change_method_implementation (MOP class_, const char *name, int class_method, const char *newname) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_3ARGS_RETURN_EXPR (class_, name, newname, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_change_method_implementation (def, name, class_method, newname); if (error) { smt_quit (def); } else { error = sm_update_class (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * db_drop_class_resolution() - This function removes a class-level resolution. * returns : error code * class(in): class pointer * super(in): class pointer * name(in): attribute/method name */ int db_drop_class_resolution (MOP class_, MOP super, const char *name) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_delete_class_resolution (def, super, name); if (error) { smt_quit (def); } else { error = sm_update_class_auto (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * pt_report_to_ersys_with_statement () - report query compilation error by * setting global ER state * return: * parser(in): handle to parser used to process the query * error_type(in): syntax, semantic, or execution * statement(in): statement tree */ void pt_report_to_ersys_with_statement (PARSER_CONTEXT * parser, const PT_ERROR_TYPE error_type, PT_NODE * statement) { PT_NODE *error_node; char buf[1000]; char *stmt_string = NULL; int err; if (parser == NULL) { return; } error_node = parser->error_msgs; if (statement) { PT_NODE_PRINT_TO_ALIAS (parser, statement, PT_CONVERT_RANGE | PT_SHORT_PRINT); stmt_string = (char *) statement->alias_print; } if (stmt_string == NULL) { stmt_string = (char *) ""; } if (error_node && error_node->node_type == PT_ZZ_ERROR_MSG) { #if 0 /* TODO */ assert (er_errid () != NO_ERROR); #endif err = er_errid (); if (!ER_IS_LOCK_TIMEOUT_ERROR (err) && !ER_IS_SERVER_DOWN_ERROR (err)) { switch (error_type) { case PT_SYNTAX: er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_SYNTAX, 2, error_node->info.error_msg.error_message, stmt_string); break; case PT_SEMANTIC: default: er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_SEMANTIC, 2, error_node->info.error_msg.error_message, stmt_string); break; case PT_EXECUTION: er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_EXECUTE, 2, error_node->info.error_msg.error_message, stmt_string); break; } } return; } /* a system error reporting error messages */ sprintf (buf, "Internal error- reporting %s error.", (error_type == PT_SYNTAX ? "syntax" : (error_type == PT_SEMANTIC ? "semantic" : "execution"))); er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_EXECUTE, 2, buf, stmt_string); } /* pt_report_to_ersys_with_statement() */
/* * disk_insert_instance - This inserts a new object in the database given a * "descriptor" for the object. * return: NO_ERROR if successful, error code otherwise * classop(in): class object * obj(in): object description * oid(in): oid of the destination */ int disk_insert_instance (MOP classop, DESC_OBJ * obj, OID * oid) { int error = NO_ERROR; HFID *hfid; int newsize; bool has_indexes; Diskrec->length = 0; if (desc_obj_to_disk (obj, Diskrec, &has_indexes)) { /* make the record larger */ newsize = -Diskrec->length + DB_PAGESIZE; free_recdes (Diskrec); Diskrec = alloc_recdes (newsize); /* try one more time */ if (Diskrec == NULL || desc_obj_to_disk (obj, Diskrec, &has_indexes) != 0) { error = ER_LDR_CANT_TRANSFORM; er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 0); } } if (!error) { hfid = get_class_heap (classop, obj->class_); if (hfid == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { HEAP_OPERATION_CONTEXT context; /* set up context */ heap_create_insert_context (&context, hfid, WS_OID (classop), Diskrec, NULL, false); /* oid is set here as a side effect */ if (heap_insert_logical (NULL, &context) != NO_ERROR) { assert (er_errid () != NO_ERROR); error = er_errid (); } else if (has_indexes) { COPY_OID (oid, &context.res_oid); error = update_indexes (WS_OID (classop), oid, Diskrec); } else { COPY_OID (oid, &context.res_oid); } } } return (error); }
/* * init_db_attribute_list () : init DB_ATTRIBUTE list for each show statement * return: error code * md(in/out): */ static int init_db_attribute_list (SHOWSTMT_METADATA * md) { int i; DB_DOMAIN *domain; DB_ATTRIBUTE *attrs = NULL, *att; if (md == NULL) { return NO_ERROR; } for (i = md->num_cols - 1; i >= 0; i--) { domain = pt_string_to_db_domain (md->cols[i].type, NULL); if (domain == NULL) { goto on_error; } domain = tp_domain_cache (domain); att = classobj_make_attribute (md->cols[i].name, domain->type, ID_ATTRIBUTE); if (att == NULL) { goto on_error; } att->domain = domain; att->auto_increment = NULL; if (attrs == NULL) { attrs = att; } else { att->order_link = attrs; attrs = att; } } md->showstmt_attrs = attrs; return NO_ERROR; on_error: while (attrs != NULL) { att = attrs; attrs = (DB_ATTRIBUTE *) att->order_link; att->order_link = NULL; classobj_free_attribute (att); } assert (er_errid () != NO_ERROR); return er_errid (); }
/* * disk_update_instance - This updates an object that had previously been * reserved with the actual contents. * return: NO_ERROR if successful, error code otherwise * classop(in): class object * obj(in): description of object * oid(in): destination oid */ int disk_update_instance (MOP classop, DESC_OBJ * obj, OID * oid) { int error = NO_ERROR; HFID *hfid; int newsize; bool has_indexes = false; Diskrec->length = 0; if (desc_obj_to_disk (obj, Diskrec, &has_indexes)) { /* make the record larger */ newsize = -Diskrec->length + DB_PAGESIZE; free_recdes (Diskrec); Diskrec = alloc_recdes (newsize); /* try one more time */ if (Diskrec == NULL || desc_obj_to_disk (obj, Diskrec, &has_indexes) != 0) { error = ER_LDR_CANT_TRANSFORM; er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 0); } } if (!error) { hfid = get_class_heap (classop, obj->class_); if (hfid == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { HEAP_OPERATION_CONTEXT update_context; heap_create_update_context (&update_context, hfid, oid, WS_OID (classop), Diskrec, NULL, UPDATE_INPLACE_NONE); if (heap_update_logical (NULL, &update_context) != NO_ERROR) { assert (er_errid () != NO_ERROR); error = er_errid (); } if (update_context.is_logical_old) { fprintf (stdout, msgcat_message (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_LOADDB, LOADDB_MSG_UPDATE_WARNING)); } else if (has_indexes) { error = update_indexes (WS_OID (classop), oid, Diskrec); } } } return (error); }
/* * db_add_attribute_internal() - This is a generic work function for adding * attributes of the various types. It saves redundant error checking code * in each of the type specific attribute routines. * return : error code * class(in/out) : class object * name(in) : attribute name * domain(in) : domain string * default_value(in): default_value * namespace(in) : namespace identifier */ int db_add_attribute_internal (MOP class_, const char *name, const char *domain, DB_VALUE * default_value, SM_NAME_SPACE name_space) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_3ARGS_RETURN_EXPR (class_, name, domain, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_add_attribute_any (def, name, domain, (DB_DOMAIN *) 0, name_space, false, NULL); if (error) { smt_quit (def); } else { if (default_value != NULL) { if (name_space == ID_CLASS || name_space == ID_CLASS_ATTRIBUTE) { error = smt_set_attribute_default (def, name, 1, default_value, DB_DEFAULT_NONE); } else { error = smt_set_attribute_default (def, name, 0, default_value, DB_DEFAULT_NONE); } } if (error) { smt_quit (def); } else { error = sm_update_class_auto (def, &newmop); if (error) { smt_quit (def); } } } } return (error); }
/* * disk_init - Initializes the loader's disk access module. * return: NO_ERROR if successful, error code otherwise */ int disk_init (void) { int error = NO_ERROR; Diskrec = alloc_recdes (DB_PAGESIZE * 4); if (Diskrec == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } return error; }
/* * disk_update_instance - This updates an object that had previously been * reserved with the acutal contents. * return: NO_ERROR if successful, error code otherwise * classop(in): class object * obj(in): description of object * oid(in): destination oid */ int disk_update_instance (MOP classop, DESC_OBJ * obj, OID * oid) { int error = NO_ERROR; HFID *hfid; int newsize; bool has_indexes = false, oldflag; Diskrec->length = 0; if (desc_obj_to_disk (obj, Diskrec, &has_indexes)) { /* make the record larger */ newsize = -Diskrec->length + DB_PAGESIZE; free_recdes (Diskrec); Diskrec = alloc_recdes (newsize); /* try one more time */ if (Diskrec == NULL || desc_obj_to_disk (obj, Diskrec, &has_indexes) != 0) { error = ER_LDR_CANT_TRANSFORM; er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 0); } } if (!error) { hfid = get_class_heap (classop, obj->class_); if (hfid == NULL) { error = er_errid (); } else if (heap_update (NULL, hfid, oid, Diskrec, &oldflag, NULL) != oid) { error = er_errid (); } else { if (oldflag) { fprintf (stdout, msgcat_message (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_LOADDB, LOADDB_MSG_UPDATE_WARNING)); } else if (has_indexes) { error = update_indexes (WS_OID (classop), oid, Diskrec); } } } return (error); }
/* * add_arg_domain() - This function describes the domain of a method argument * used for run time consistency checking by the interpreter. If the index * argument is 0, the domain is used as the domain of the return value of * the method. Otherwise, the index references the arguments of the method * from 1 to n. * return : error code * class(in): class object * name(in): method name * class_method(in): class method flag * index(in): argument index (zero is return value) * initial_domain(in): initialize flag. * domain(in): domain descriptor string * * note : Argument indexes can be specified that do not necessarily increase * by 1, i.e., arg1, arg2, arg5 leaves arg3 and arg4 unspecified and * logically void. * If the supplied index is greater than any of the indexes that were * previously supplied for the arguments, the argument list of the * method is extended. */ static int add_arg_domain (DB_OBJECT * class_, const char *name, int class_method, int index, int initial_domain, const char *domain) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_2ARGS_RETURN_EXPR (class_, name, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { if (domain == NULL) { error = smt_assign_argument_domain (def, name, class_method, NULL, index, NULL, (DB_DOMAIN *) 0); } else { if (initial_domain) { error = smt_assign_argument_domain (def, name, class_method, NULL, index, domain, (DB_DOMAIN *) 0); } else { error = smt_add_set_argument_domain (def, name, class_method, NULL, index, domain, (DB_DOMAIN *) 0); } } if (error) { smt_quit (def); } else { error = sm_update_class (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * logwr_flush_header_page - * * return: * Note: */ void logwr_flush_header_page (void) { PAGEID phy_pageid; PAGEID logical_pageid; int nbytes; if (logwr_Gl.loghdr_pgptr == NULL) { return; } /* flush current archiving status */ logwr_Gl.hdr.nxarv_num = logwr_Gl.last_arv_num; logwr_Gl.hdr.last_deleted_arv_num = logwr_Gl.last_deleted_arv_num; logwr_Gl.hdr.nxarv_pageid = logwr_Gl.last_arv_fpageid; logwr_Gl.hdr.nxarv_phy_pageid = logwr_to_physical_pageid (logwr_Gl.last_arv_fpageid); memcpy (logwr_Gl.loghdr_pgptr->area, &logwr_Gl.hdr, sizeof (logwr_Gl.hdr)); logical_pageid = LOGPB_HEADER_PAGE_ID; phy_pageid = logwr_to_physical_pageid (logical_pageid); /* logwr_Gl.append_vdes is only changed * while starting or finishing or recovering server. * So, log cs is not needed. */ if (fileio_write (NULL, logwr_Gl.append_vdes, logwr_Gl.loghdr_pgptr, phy_pageid, LOG_PAGESIZE) == NULL || (logwr_Gl.mode != LOGWR_MODE_ASYNC && fileio_synchronize (NULL, logwr_Gl.append_vdes, logwr_Gl.active_name)) == NULL_VOLDES) { if (er_errid () == ER_IO_WRITE_OUT_OF_SPACE) { nbytes = ((logwr_Gl.hdr.npages + 1 - logical_pageid) * logwr_Gl.hdr.db_logpagesize); er_set (ER_FATAL_ERROR_SEVERITY, ARG_FILE_LINE, ER_LOG_WRITE_OUT_OF_SPACE, 4, logical_pageid, phy_pageid, logwr_Gl.active_name, nbytes); } else { er_set_with_oserror (ER_FATAL_ERROR_SEVERITY, ARG_FILE_LINE, ER_LOG_WRITE, 3, logical_pageid, phy_pageid, logwr_Gl.active_name); } } /* save last checkpoint pageid */ logwr_Gl.last_chkpt_pageid = logwr_Gl.hdr.chkpt_lsa.pageid; er_log_debug (ARG_FILE_LINE, "logwr_flush_header_page, ha_server_state=%s, ha_file_status=%s\n", css_ha_server_state_string (logwr_Gl.hdr.ha_server_state), logwr_Gl.hdr.ha_file_status == LOG_HA_FILESTAT_SYNCHRONIZED ? "sync" : "unsync"); }
/* * realloc_instance_table - Extends the instance array within a CLASS_TABLE. * return: NO_ERROR if successful, error code otherwise * table(in/out): class table to extend * newcount(in): new size of the instance table */ static int realloc_instance_table (CLASS_TABLE * table, int newcount) { INST_INFO *tmp_inst_info; int i; /* * only do this if the new count is larger than the existing * table, shouldn't see this */ if (newcount > table->count) { tmp_inst_info = (INST_INFO *) realloc (table->instances, newcount * sizeof (INST_INFO)); if (tmp_inst_info == NULL) { er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_LDR_MEMORY_ERROR, 0); return er_errid (); } for (i = table->count; i < newcount; i++) { tmp_inst_info[i].flags = 0; OID_SET_NULL (&(tmp_inst_info[i].oid)); } table->instances = tmp_inst_info; table->count = newcount; } return NO_ERROR; }
/* * overflow_delete_internal () - * return: NO_ERROR * ovf_vfid(in): File where the overflow data is stored * WARNING: MUST BE THE SAME AS IT WAS GIVEN DURING INSERT * vpid(in): * pgptr(in): */ static int overflow_delete_internal (THREAD_ENTRY * thread_p, const VFID * ovf_vfid, VPID * vpid, PAGE_PTR pgptr) { int ret; ret = pgbuf_invalidate (thread_p, pgptr); if (ret != NO_ERROR) { goto exit_on_error; } ret = file_dealloc_page (thread_p, ovf_vfid, vpid); if (ret != NO_ERROR) { goto exit_on_error; } return ret; exit_on_error: return (ret == NO_ERROR && (ret = er_errid ()) == NO_ERROR) ? ER_FAILED : ret; }
/* * update_indexes - Updates the indexes for an instance that is being inserted. * return: NO_ERROR if successful, error code otherwise * class_oid(in): class oid * obj_oid(in): instance oid * rec(in): record with new object * Note: * Updates the indexes for an instance that is being inserted. * This only calls btree_insert because for use in the loader, we will never * be updating existing instances. When the loader encounters a forward * reference to an instance, it will use heap_reserve_address but will * not attempt to store a default instance at that address. * This means that there will never be an existing entry in the btree when * we finally get around to storing the actual object contents. If this * situation ever changes, then we will need to call btree_update here * instead. This will require the current key value which must be * extracted from the hf record being replaced. * See locator_force to see how this can be done. * * Moral, avoid writing the instance record until absolutely necessary, * and then do it only once. */ static int update_indexes (OID * class_oid, OID * obj_oid, RECDES * rec) { int error = NO_ERROR; if (locator_add_or_remove_index (NULL, rec, obj_oid, class_oid, true, SINGLE_ROW_INSERT, (HEAP_SCANCACHE *) NULL, /* ejin: for replication... */ false, /* 7th arg -> data or schema */ false, NULL, /* 8th arg -> make repl. log or not */ NULL) != NO_ERROR) { assert (er_errid () != NO_ERROR); error = er_errid (); } return error; }
static int set_server_error (int error) { int server_error; switch (error) { case CANT_ALLOC_BUFFER: server_error = ER_NET_CANT_ALLOC_BUFFER; er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, server_error, 0); break; case RECORD_TRUNCATED: server_error = ER_NET_DATA_TRUNCATED; er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, server_error, 0); break; case REQUEST_REFUSED: server_error = er_errid (); break; case SERVER_ABORTED: server_error = er_errid (); /* those errors are generated by the net_server_request() * so that do not fall to server crash handling */ switch (server_error) { case ER_DB_NO_MODIFICATIONS: er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, server_error, 0); return (server_error); case ER_AU_DBA_ONLY: er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, server_error, 1, ""); return (server_error); } /* no break; fall through */ default: server_error = ER_NET_SERVER_CRASHED; er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, server_error, 0); break; } er_log_debug (ARG_FILE_LINE, "set_server_error(%d) server_error %d\n", error, server_error); db_Connect_status = DB_CONNECTION_STATUS_NOT_CONNECTED; return (server_error); }
/* * pt_report_to_ersys () - report query compilation error by * setting global ER state * return: * parser(in): handle to parser used to process the query * error_type(in): syntax, semantic, or execution */ void pt_report_to_ersys (const PARSER_CONTEXT * parser, const PT_ERROR_TYPE error_type) { PT_NODE *error_node; int err; char buf[1000]; error_node = parser->error_msgs; if (error_node && error_node->node_type == PT_ZZ_ERROR_MSG) { #if 0 /* TODO */ assert (er_errid () != NO_ERROR); #endif err = er_errid (); if (!ER_IS_LOCK_TIMEOUT_ERROR (err) && !ER_IS_SERVER_DOWN_ERROR (err)) { switch (error_type) { case PT_SYNTAX: er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_SYNTAX, 2, error_node->info.error_msg.error_message, ""); break; case PT_SEMANTIC: default: er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_SEMANTIC, 2, error_node->info.error_msg.error_message, ""); break; case PT_EXECUTION: er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_EXECUTE, 2, error_node->info.error_msg.error_message, ""); break; } } return; } /* a system error reporting error messages */ sprintf (buf, "Internal error- reporting %s error.", (error_type == PT_SYNTAX ? "syntax" : (error_type == PT_SEMANTIC ? "semantic" : "execution"))); er_set (ER_SYNTAX_ERROR_SEVERITY, ARG_FILE_LINE, ER_PT_EXECUTE, 2, buf, ""); }
/* * db_drop_super() - This function removes a superclass link from a class. * The attributes and methods that were inherited from the superclass are * removed, and the changes are propagated to the subclasses. If the class * is partitioned, function returns ER_NOT_ALLOWED_ACCESS_TO_PARTITION. * return : error code * class(in): class or instance pointer * super(in): class pointer * * note : Any resulting conflicts are resolved automatically by the system. * If the system's resolution is unsatisfactory, it can be redefined * with the db_add_resolution() function or the db_add_class_resolution() * function, as appropriate. */ int db_drop_super (MOP class_, MOP super) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_2ARGS_RETURN_EXPR (class_, super, ER_OBJ_INVALID_ARGUMENTS); error = do_check_partitioned_class (class_, CHECK_PARTITION_SUBS, NULL); if (!error) { def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_delete_super (def, super); if (error) { smt_quit (def); } else { error = sm_update_class_auto (def, &newmop); if (error) { smt_quit (def); } } } } return (error); }
/* * db_drop_set_attribute_domain() - This function used to remove domain * specifications for attributes whose original domain was "set", * "multi_set", or "sequence". The set valued attributes can be given * further domain information using db_add_element_domain which defines * the allowed types for elements of the set. Use db_drop_element_domain * to remove entries from the set domain list. * returns/side-effects: error code * class(in) : class or instance * name(in) : attribute name * domain(in): domain name * */ int db_drop_set_attribute_domain (MOP class_, const char *name, int class_attribute, const char *domain) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_3ARGS_RETURN_EXPR (class_, name, domain, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_delete_set_attribute_domain (def, name, class_attribute, domain, (DB_DOMAIN *) 0); if (error) { smt_quit (def); } else { error = sm_update_class (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * db_drop_method_files() - This function removes all of the currently defined * method files for a class. This can be used in cases where you want to * completely respecify the file list without making multiple calls to * db_drop_method_file(). * return : error code. * class(in): class or instance. */ int db_drop_method_files (MOP class_) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_1ARG_RETURN_EXPR (class_, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_reset_method_files (def); if (error) { smt_quit (def); } else { error = sm_update_class (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * db_add_super_internal() - This function adds a super class to a class if it * did not already exist. * return : error code * class(in): class or instance * super(in): super class */ int db_add_super_internal (MOP class_, MOP super) { int error = NO_ERROR; SM_TEMPLATE *def; MOP newmop; CHECK_CONNECT_ERROR (); CHECK_MODIFICATION_ERROR (); CHECK_2ARGS_RETURN_EXPR (class_, super, ER_OBJ_INVALID_ARGUMENTS); def = smt_edit_class_mop (class_, AU_ALTER); if (def == NULL) { assert (er_errid () != NO_ERROR); error = er_errid (); } else { error = smt_add_super (def, super); if (error) { smt_quit (def); } else { error = sm_update_class_auto (def, &newmop); if (error) { smt_quit (def); } } } return (error); }
/* * overflow_flush_internal () - * return: NO_ERROR * pgptr(in): */ static int overflow_flush_internal (THREAD_ENTRY * thread_p, PAGE_PTR pgptr) { int ret = NO_ERROR; if (pgbuf_flush_with_wal (thread_p, pgptr) == NULL) { goto exit_on_error; } return ret; exit_on_error: return (ret == NO_ERROR && (ret = er_errid ()) == NO_ERROR) ? ER_FAILED : ret; }
static int cursor_fetch_oids (CURSOR_ID * cursor_id_p, int oid_index, DB_FETCH_MODE instant_fetch_mode, DB_FETCH_MODE class_fetch_mode) { int i; OID tmp_oid; MOBJ mobj; if (oid_index == 0) { /* nothing to fetch */ return NO_ERROR; } /* form the MOP set from the existing oid_set */ for (i = 0; i < oid_index; i++) { OR_GET_OID (&cursor_id_p->oid_set[i], &tmp_oid); cursor_id_p->mop_set[i] = ws_mop (&tmp_oid, (MOP) NULL); } if (oid_index == 1) { mobj = locator_fetch_object (cursor_id_p->mop_set[0], instant_fetch_mode); } else { mobj = locator_fetch_set (oid_index, cursor_id_p->mop_set, instant_fetch_mode, class_fetch_mode, false); } if (mobj == NULL && er_errid () != ER_HEAP_UNKNOWN_OBJECT) { return ER_FAILED; } return NO_ERROR; }
/* * pt_end_query() - * return: * parser(in): parser context * query_id_self(in): */ void pt_end_query (PARSER_CONTEXT * parser, QUERY_ID query_id_self) { assert (parser != NULL); assert (query_id_self != 0); assert (query_id_self == NULL_QUERY_ID || query_id_self > 0); if (parser->query_id > 0) { if (er_errid () != ER_LK_UNILATERALLY_ABORTED) { qmgr_end_query (parser->query_id); } } else { assert (parser->query_id == 0); } parser->query_id = query_id_self; }
static PT_NODE * pt_check_access_status (PARSER_CONTEXT * parser, PT_NODE * node) { DB_VALUE oid_val; MOP classop; PT_NODE *entity = NULL; PT_NODE *derived_table = NULL; PT_NODE *arg = NULL; if (!au_is_dba_group_member (Au_user)) { PT_ERRORmf (parser, NULL, MSGCAT_SET_ERROR, -(ER_AU_DBA_ONLY), "show access status"); return node; } entity = node->info.query.q.select.from; assert (entity != NULL); derived_table = entity->info.spec.derived_table; assert (derived_table != NULL); classop = sm_find_class ("db_user"); if (classop == NULL) { assert (er_errid () != NO_ERROR); PT_ERRORc (parser, node, er_msg ()); return node; } db_make_oid (&oid_val, &classop->oid_info.oid); arg = pt_dbval_to_value (parser, &oid_val); derived_table->info.showstmt.show_args = parser_append_node (arg, derived_table->info.showstmt.show_args); return node; }