Skip to content

Commit

Permalink
[CBRD-25481] Corrects an error in unloaddb when the JSON type column …
Browse files Browse the repository at this point in the history
…contains data larger than 1MB (CUBRID#5357)

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

* Fixed the phenomenon of not being able to process large amounts of json type data and falling into an infinite loop when  performing unloaddb.
* Changed the buffer that should contain plain text to write strings larger than that directly to a file.
  • Loading branch information
ctshim authored and mhoh3963 committed Aug 6, 2024
1 parent c4e526b commit 1adbf7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions src/loaddb/load_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ text_print_flush (TEXT_OUTPUT * tout)
* ...(in): arguments
*/
int
text_print (TEXT_OUTPUT * tout, const char *buf, int buflen, char const *fmt, ...)
text_print (TEXT_OUTPUT * tout, const char *buf, int buflen, const char *fmt, ...)
{
int error = NO_ERROR;
int nbytes, size;
Expand Down Expand Up @@ -502,7 +502,30 @@ text_print (TEXT_OUTPUT * tout, const char *buf, int buflen, char const *fmt, ..
else
{ /* need more buffer */
CHECK_PRINT_ERROR (text_print_flush (tout));
goto start; /* retry */
if (tout->iosize > nbytes)
{
goto start; /* retry */
}

if (buflen > 0)
{
if (buflen != (int) fwrite (buf, 1, buflen, tout->fp))
{
return ER_IO_WRITE;
}
}
else
{
va_start (ap, fmt);
if (nbytes != vfprintf (tout->fp, fmt, ap))
{
va_end (ap);
return ER_IO_WRITE;
}
va_end (ap);
}

return NO_ERROR;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/loaddb/load_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct text_output
} TEXT_OUTPUT;

extern int text_print_flush (TEXT_OUTPUT * tout);
extern int text_print (TEXT_OUTPUT * tout, const char *buf, int buflen, char const *fmt, ...);
extern int text_print (TEXT_OUTPUT * tout, const char *buf, int buflen, const char *fmt, ...);
extern DESC_OBJ *make_desc_obj (SM_CLASS * class_);
extern int desc_obj_to_disk (DESC_OBJ * obj, RECDES * record, bool * index_flag);
extern int desc_disk_to_obj (MOP classop, SM_CLASS * class_, RECDES * record, DESC_OBJ * obj);
Expand Down

0 comments on commit 1adbf7e

Please sign in to comment.