Skip to content

Commit

Permalink
[CBRD-25064] change to return success when performing execute standal…
Browse files Browse the repository at this point in the history
…one's loaddb with zero-sized object files. (#4995)

http://jira.cubrid.org/browse/CBRD-25064

backport of (#4988)
  • Loading branch information
mhoh3963 authored Feb 27, 2024
1 parent 8505354 commit a25901c
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/loaddb/load_sa_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6203,6 +6203,7 @@ ldr_sa_load (load_args *args, int *status, bool *interrupted)
int defaults = 0;
int fails = 0;
int lastcommit = 0;
bool is_emptyfile = false;
int ldr_init_ret = NO_ERROR;

std::ifstream object_file (args->object_file);
Expand Down Expand Up @@ -6230,6 +6231,14 @@ ldr_sa_load (load_args *args, int *status, bool *interrupted)
ldr_register_post_commit_handler ();
}

/* get the size of object file */
object_file.seekg (0, std::ios::end);
if (object_file.tellg() <= 0)
{
is_emptyfile = true;
}
object_file.seekg (0, std::ios::beg);

/* Check if we need to perform syntax checking. */
if (!args->load_only)
{
Expand All @@ -6239,7 +6248,10 @@ ldr_sa_load (load_args *args, int *status, bool *interrupted)
{
ldr_init_ret = ldr_Driver->get_class_installer ().install_class (args->table_name.c_str ());
}
ldr_Driver->parse (object_file);
if (!is_emptyfile)
{
ldr_Driver->parse (object_file);
}
ldr_stats (&errors, &objects, &defaults, &lastcommit, &fails);
}
else
Expand Down Expand Up @@ -6296,7 +6308,10 @@ ldr_sa_load (load_args *args, int *status, bool *interrupted)
ldr_Driver->get_class_installer ().install_class (args->table_name.c_str ());
}

ldr_Driver->parse (object_file);
if (!is_emptyfile)
{
ldr_Driver->parse (object_file);
}
ldr_stats (&errors, &objects, &defaults, &lastcommit, &fails);

if (errors)
Expand All @@ -6320,12 +6335,9 @@ ldr_sa_load (load_args *args, int *status, bool *interrupted)
}
else
{
if (objects || fails)
{
print_log_msg (1,
msgcat_message (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_LOADDB,
LOADDB_MSG_INSERT_AND_FAIL_COUNT), objects, fails);
}
print_log_msg (1,
msgcat_message (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_LOADDB,
LOADDB_MSG_INSERT_AND_FAIL_COUNT), objects, fails);

if (defaults)
{
Expand Down

0 comments on commit a25901c

Please sign in to comment.