Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hgryoo committed Apr 30, 2024
1 parent 39dc5c8 commit 780c669
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,8 @@ public void packOID(SOID oid) {
packShort(oid.volId);
}

private static final byte[] dummy = {0};

public void packCString(byte[] value) {
if (value == null) {
value = dummy;
}
int len = value.length;

if (len < DataUtilities.MAX_SMALL_STRING_SIZE) {
ensureSpace(value.length + 1 + DataUtilities.INT_ALIGNMENT); // str + len + align
buffer.put((byte) len);
Expand Down
28 changes: 9 additions & 19 deletions src/jsp/jsp_cl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ jsp_find_stored_procedure (const char *name)
* Note:
*/


MOP
jsp_find_stored_procedure_code (const char *name)
{
Expand Down Expand Up @@ -1018,8 +1019,7 @@ static int
drop_stored_procedure (const char *name, SP_TYPE_ENUM expected_type)
{
MOP sp_mop, arg_mop, owner;
DB_VALUE sp_type_val, arg_cnt_val, args_val, owner_val, target_val, lang_val, generated_val, temp;
SP_LANG_ENUM lang_type;
DB_VALUE sp_type_val, arg_cnt_val, args_val, owner_val, generated_val, target_val, temp;
SP_TYPE_ENUM real_type;
std::string class_name;
const char *target;
Expand Down Expand Up @@ -1084,29 +1084,19 @@ drop_stored_procedure (const char *name, SP_TYPE_ENUM expected_type)
}

// delete _db_stored_procedure_code
err = db_get (sp_mop, SP_ATTR_LANG, &lang_val);
err = db_get (sp_mop, SP_ATTR_TARGET, &target_val);
if (err != NO_ERROR)
{
goto error;
}

lang_type = (SP_LANG_ENUM) db_get_int (&lang_val);
if (lang_type == SP_LANG_PLCSQL)
{
err = db_get (sp_mop, SP_ATTR_TARGET, &target_val);
if (err != NO_ERROR)
{
goto error;
}

target = db_get_string (&target_val);
class_name = get_class_name (target);
target = db_get_string (&target_val);
class_name = get_class_name (target);

err = drop_stored_procedure_code (class_name.c_str ());
if (err != NO_ERROR)
{
goto error;
}
err = drop_stored_procedure_code (class_name.c_str ());
if (err != NO_ERROR)
{
goto error;
}

err = db_get (sp_mop, SP_ATTR_ARG_COUNT, &arg_cnt_val);
Expand Down
26 changes: 22 additions & 4 deletions src/jsp/sp_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,24 @@ sp_add_stored_procedure_code (SP_CODE_INFO &info)
goto error;
}

db_make_string (&value, info.sp_name.data ());
err = dbt_put_internal (obt_p, SP_ATTR_NAME, &value);
db_make_string (&value, info.created_time.data ());
err = dbt_put_internal (obt_p, SP_ATTR_TIMESTAMP, &value);
pr_clear_value (&value);
if (err != NO_ERROR)
{
goto error;
}

db_make_object (&value, info.owner);
err = dbt_put_internal (obt_p, SP_ATTR_OWNER, &value);
pr_clear_value (&value);
if (err != NO_ERROR)
{
goto error;
}

db_make_string (&value, info.name.data ());
err = dbt_put_internal (obt_p, SP_ATTR_CLS_NAME, &value);
pr_clear_value (&value);
if (err != NO_ERROR)
{
Expand All @@ -695,7 +711,8 @@ sp_add_stored_procedure_code (SP_CODE_INFO &info)
goto error;
}

db_make_string (&value, info.scode.data ());
db_make_varchar (&value, DB_DEFAULT_PRECISION, info.scode.data (), info.scode.length (), INTL_CODESET_UTF8,
LANG_COLL_UTF8_BINARY);
err = dbt_put_internal (obt_p, SP_ATTR_SOURCE_CODE, &value);
pr_clear_value (&value);
if (err != NO_ERROR)
Expand All @@ -712,7 +729,8 @@ sp_add_stored_procedure_code (SP_CODE_INFO &info)
goto error;
}

db_make_string (&value, info.ocode.data ());
db_make_varchar (&value, DB_DEFAULT_PRECISION, info.ocode.data (), info.ocode.length (), INTL_CODESET_UTF8,
LANG_COLL_UTF8_BINARY);
err = dbt_put_internal (obt_p, SP_ATTR_OBJECT_CODE, &value);
pr_clear_value (&value);
if (err != NO_ERROR)
Expand Down
5 changes: 4 additions & 1 deletion src/jsp/sp_catalog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ typedef sp_directive SP_DIRECTIVE_ENUM;

struct sp_code_info
{
std::string sp_name;
std::string name;
std::string created_time;
MOP owner;
int is_static;
int is_system_generated;
int stype;
std::string scode;
int otype;
Expand Down
10 changes: 7 additions & 3 deletions src/object/schema_system_catalog_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ namespace cubschema
);
}


system_catalog_definition
system_catalog_initializer::get_stored_procedure_code ()
{
Expand All @@ -898,17 +899,20 @@ namespace cubschema
CT_STORED_PROC_CODE_NAME,
// columns
{
{"sp_name", format_varchar (255)},
{"name", format_varchar (65535)}, // java's name limit
{"created_time", format_varchar (16)},
{"owner", AU_USER_CLASS_NAME},
{"is_static", "integer"},
{"is_system_generated", "integer"},
{"stype", "integer"},
{"scode", format_varchar (1073741823)},
{"otype", "integer"},
{"ocode", format_varchar (1073741823)}
},
// constraints
{
{DB_CONSTRAINT_INDEX, "", {"name", nullptr}, false},
{DB_CONSTRAINT_NOT_NULL, "", {"ocode", nullptr}, false}
{DB_CONSTRAINT_UNIQUE, "", {"name", nullptr}, false},
{DB_CONSTRAINT_UNIQUE, "", {"name", "created_time", nullptr}, false},
},
// authorization
{
Expand Down

0 comments on commit 780c669

Please sign in to comment.