LCOV - code coverage report
Current view: top level - data/source/storage - data_database_sql_builder.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 793 887 89.4 %
Date: 2024-10-26 21:44:38 Functions: 37 37 100.0 %

          Line data    Source code
       1             : /* File: data_database_sql_builder.c; Copyright and License: see below */
       2             : 
       3             : #include "storage/data_database_sql_builder.h"
       4             : #include "entity/data_id.h"
       5             : #include "u8/u8_trace.h"
       6             : #include "u8/u8_log.h"
       7             : #include "utf8stringbuf/utf8string.h"
       8             : #include "utf8stringbuf/utf8stringview.h"
       9             : #include <assert.h>
      10             : 
      11             : /*!
      12             :  *  \brief value separator string constant to insert a diagram or classifier or other table-row
      13             :  */
      14             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR = ",";
      15             : 
      16             : /*!
      17             :  *  \brief string start marker string constant to insert/update a diagram
      18             :  */
      19             : static const char *DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START = "\'";
      20             : 
      21             : /*!
      22             :  *  \brief string end marker string constant to insert/update a diagram
      23             :  */
      24             : static const char *DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END = "\'";
      25             : 
      26             : /*!
      27             :  *  \brief constant representing the null value
      28             :  */
      29             : static const char *DATA_DATABASE_SQL_BUILDER_NULL_VALUE = "NULL";
      30             : 
      31             : /*!
      32             :  *  \brief translation table to encode strings for usage in string literals
      33             :  *
      34             :  *  Note: This table is not suitable for searches using the LIKE operator because _ and % are not handled.
      35             :  */
      36             : const char *const DATA_DATABASE_SQL_BUILDER_SQL_ENCODE[][2] = {
      37             :     { "'", "''" },
      38             :     { NULL, NULL }
      39             : };
      40             : 
      41          72 : void data_database_sql_builder_init ( data_database_sql_builder_t *this_ )
      42             : {
      43          72 :     U8_TRACE_BEGIN();
      44             :     /* data_diagram_t is the biggest data structure that may contain lots of quote symbols; */
      45             :     /* an additional SQL statement around is also added, e.g. DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_WITH_ID_PREFIX */
      46             :     assert( sizeof((*this_).private_sql_buffer) > 2*sizeof(data_diagram_t)+1024 );
      47             : 
      48             :     /* initialize a memory output stream */
      49          72 :     universal_memory_output_stream_init( &((*this_).plain_out),
      50          72 :                                          &((*this_).private_sql_buffer),
      51             :                                          sizeof((*this_).private_sql_buffer),
      52             :                                          UNIVERSAL_MEMORY_OUTPUT_STREAM_0TERM_UTF8
      53             :                                        );
      54             :     universal_output_stream_t *const plain_output
      55          72 :         = universal_memory_output_stream_get_output_stream( &((*this_).plain_out) );
      56             : 
      57          72 :     utf8stream_writer_init( &((*this_).plain), plain_output );
      58             : 
      59             :     /* initialize an sql escaped output stream */
      60          72 :     universal_escaping_output_stream_init( &((*this_).escaped_out),
      61             :                                            &DATA_DATABASE_SQL_BUILDER_SQL_ENCODE,
      62             :                                            plain_output
      63             :                                          );
      64             :     universal_output_stream_t *const escaped_output
      65          72 :         = universal_escaping_output_stream_get_output_stream( &((*this_).escaped_out) );
      66             : 
      67          72 :     utf8stream_writer_init( &((*this_).escaped), escaped_output );
      68             : 
      69          72 :     U8_TRACE_END();
      70          72 : }
      71             : 
      72          72 : void data_database_sql_builder_destroy ( data_database_sql_builder_t *this_ )
      73             : {
      74          72 :     U8_TRACE_BEGIN();
      75             : 
      76             :     /* de-initialize an sql escaped output stream */
      77          72 :     utf8stream_writer_destroy( &((*this_).escaped) );
      78          72 :     universal_escaping_output_stream_destroy( &((*this_).escaped_out) );
      79             : 
      80             :     /* de-initialize an output stream */
      81          72 :     utf8stream_writer_destroy( &((*this_).plain) );
      82          72 :     universal_memory_output_stream_destroy( &((*this_).plain_out) );
      83             : 
      84          72 :     U8_TRACE_END();
      85          72 : }
      86             : 
      87             : /* ================================ DIAGRAM ================================ */
      88             : 
      89             : /*!
      90             :  *  \brief prefix string constant to insert a diagram
      91             :  */
      92             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_PREFIX =
      93             :     "INSERT INTO diagrams (parent_id,diagram_type,stereotype,name,description,list_order,display_flags,uuid) VALUES (";
      94             : 
      95             : /*!
      96             :  *  \brief prefix string constant to insert a diagram with predefined id
      97             :  */
      98             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_WITH_ID_PREFIX =
      99             :     "INSERT INTO diagrams (id,parent_id,diagram_type,stereotype,name,description,list_order,display_flags,uuid) VALUES (";
     100             : 
     101             : /*!
     102             :  *  \brief postfix string constant to insert a diagram
     103             :  */
     104             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_POSTFIX = ");";
     105             : 
     106             : /*!
     107             :  *  \brief prefix string constant to delete a diagram
     108             :  */
     109             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAM_PREFIX =
     110             :     "DELETE FROM diagrams WHERE (id=";
     111             : 
     112             : /*!
     113             :  *  \brief postfix string constant to delete a diagram
     114             :  */
     115             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAM_POSTFIX = ");";
     116             : 
     117             : /*!
     118             :  *  \brief prefix string constant to update a diagram
     119             :  */
     120             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX = "UPDATE diagrams SET ";
     121             : 
     122             : /*!
     123             :  *  \brief field name string constant to be used for updating a diagram
     124             :  */
     125             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_PARENT_ID = "parent_id=";
     126             : 
     127             : /*!
     128             :  *  \brief field name string constant to be used for updating a diagram
     129             :  */
     130             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_TYPE = "diagram_type=";
     131             : 
     132             : /*!
     133             :  *  \brief field name string constant to be used for updating a diagram
     134             :  */
     135             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_STEREOTYPE = "stereotype=";
     136             : 
     137             : /*!
     138             :  *  \brief field name string constant to be used for updating a diagram
     139             :  */
     140             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_NAME = "name=";
     141             : 
     142             : /*!
     143             :  *  \brief field name string constant to be used for updating a diagram
     144             :  */
     145             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_LIST_ORDER = "list_order=";
     146             : 
     147             : /*!
     148             :  *  \brief field name string constant to be used for updating a diagram
     149             :  */
     150             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_DESCRIPTION = "description=";
     151             : 
     152             : /*!
     153             :  *  \brief infix string constant to update a diagram
     154             :  */
     155             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX = " WHERE id=";
     156             : 
     157             : /*!
     158             :  *  \brief postfix string constant to update a diagram
     159             :  */
     160             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX = ";";
     161             : 
     162         200 : u8_error_t data_database_sql_builder_build_create_diagram_command ( data_database_sql_builder_t *this_, const data_diagram_t *diagram )
     163             : {
     164         200 :     U8_TRACE_BEGIN();
     165         200 :     assert( NULL != diagram );
     166         200 :     u8_error_t out_err = U8_ERROR_NONE;
     167         200 :     u8_error_t result = U8_ERROR_NONE;
     168             : 
     169         200 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     170             : 
     171         200 :     if ( DATA_ROW_ID_VOID == data_diagram_get_row_id( diagram )  )
     172             :     {
     173         164 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_PREFIX );
     174             :     }
     175             :     else
     176             :     {
     177          36 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_WITH_ID_PREFIX );
     178          36 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagram_get_row_id( diagram ) );
     179          36 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     180             :     }
     181         200 :     if ( DATA_ROW_ID_VOID == data_diagram_get_parent_row_id( diagram ) )
     182             :     {
     183          50 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_NULL_VALUE );
     184             :     }
     185             :     else
     186             :     {
     187         150 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagram_get_parent_row_id( diagram ) );
     188             :     }
     189         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     190         200 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagram_get_diagram_type( diagram ) );
     191         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     192             : 
     193             :     /* stereotype */
     194         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     195         200 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     196         200 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_diagram_get_stereotype_const( diagram ) );
     197         200 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     198         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     199             : 
     200         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     201             : 
     202             :     /* name */
     203         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     204         200 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     205         200 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_diagram_get_name_const( diagram ) );
     206         200 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     207         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     208             : 
     209         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     210             : 
     211             :     /* description */
     212         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     213         200 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     214         200 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_diagram_get_description_const( diagram ) );
     215         200 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     216         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     217             : 
     218         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     219         200 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagram_get_list_order( diagram ) );
     220         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     221         200 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagram_get_display_flags( diagram ) );
     222         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     223             : 
     224         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     225         200 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     226         200 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_diagram_get_uuid_const( diagram ) );
     227         200 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     228         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     229             : 
     230         200 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAM_POSTFIX );
     231             : 
     232         200 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     233             : 
     234         200 :     if ( out_err != U8_ERROR_NONE )
     235             :     {
     236           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     237           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     238             :     }
     239             : 
     240         200 :     U8_TRACE_END_ERR( result );
     241         200 :     return( result );
     242             : }
     243             : 
     244         133 : u8_error_t data_database_sql_builder_build_delete_diagram_command ( data_database_sql_builder_t *this_, data_row_id_t diagram_id )
     245             : {
     246         133 :     U8_TRACE_BEGIN();
     247         133 :     u8_error_t out_err = U8_ERROR_NONE;
     248         133 :     u8_error_t result = U8_ERROR_NONE;
     249             : 
     250         133 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     251             : 
     252         133 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAM_PREFIX );
     253         133 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     254         133 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAM_POSTFIX );
     255             : 
     256         133 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     257             : 
     258         133 :     if ( out_err != U8_ERROR_NONE )
     259             :     {
     260           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     261           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     262             :     }
     263             : 
     264         133 :     U8_TRACE_END_ERR( result );
     265         133 :     return( result );
     266             : }
     267             : 
     268           4 : u8_error_t data_database_sql_builder_build_update_diagram_stereotype_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagram_id, const char *new_diagram_stereotype )
     269             : {
     270           4 :     U8_TRACE_BEGIN();
     271           4 :     assert( NULL != new_diagram_stereotype );
     272           4 :     u8_error_t out_err = U8_ERROR_NONE;
     273           4 :     u8_error_t result = U8_ERROR_NONE;
     274             : 
     275           4 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     276             : 
     277           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX );
     278           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_STEREOTYPE );
     279             : 
     280           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     281           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     282             :     {
     283             :         /* prepare a shortened_text to */
     284             :         /* view the string but limited to the maximum allowed bytes: */
     285             :         utf8stringview_t shortened_text;
     286           4 :         const size_t new_length = utf8string_get_length( new_diagram_stereotype );
     287           4 :         if ( new_length <= DATA_DIAGRAM_MAX_STEREOTYPE_LENGTH )
     288             :         {
     289           4 :             utf8stringview_init_str( &shortened_text, new_diagram_stereotype );
     290             :         }
     291             :         else
     292             :         {
     293           0 :             out_err |= UTF8ERROR_TRUNCATED;
     294           0 :             utf8stringview_init( &shortened_text, new_diagram_stereotype, DATA_DIAGRAM_MAX_STEREOTYPE_LENGTH );
     295             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
     296             :         }
     297           4 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
     298           4 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     299           4 :         utf8stringview_destroy( &shortened_text );
     300             :     }
     301           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     302             : 
     303           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX );
     304             : 
     305           4 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     306           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX );
     307             : 
     308           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     309             : 
     310           4 :     if ( out_err != U8_ERROR_NONE )
     311             :     {
     312           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     313           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     314             :     }
     315             : 
     316           4 :     U8_TRACE_END_ERR( result );
     317           4 :     return( result );
     318             : }
     319             : 
     320           6 : u8_error_t data_database_sql_builder_build_update_diagram_name_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagram_id, const char *new_diagram_name )
     321             : {
     322           6 :     U8_TRACE_BEGIN();
     323           6 :     assert( NULL != new_diagram_name );
     324           6 :     u8_error_t out_err = U8_ERROR_NONE;
     325           6 :     u8_error_t result = U8_ERROR_NONE;
     326             : 
     327           6 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     328             : 
     329           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX );
     330           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_NAME );
     331             : 
     332           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     333           6 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     334             :     {
     335             :         /* prepare a shortened_text to */
     336             :         /* view the string but limited to the maximum allowed bytes: */
     337             :         utf8stringview_t shortened_text;
     338           6 :         const size_t new_length = utf8string_get_length( new_diagram_name );
     339           6 :         if ( new_length <= DATA_DIAGRAM_MAX_NAME_LENGTH )
     340             :         {
     341           6 :             utf8stringview_init_str( &shortened_text, new_diagram_name );
     342             :         }
     343             :         else
     344             :         {
     345           0 :             out_err |= UTF8ERROR_TRUNCATED;
     346           0 :             utf8stringview_init( &shortened_text, new_diagram_name, DATA_DIAGRAM_MAX_NAME_LENGTH );
     347             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
     348             :         }
     349           6 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
     350           6 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     351           6 :         utf8stringview_destroy( &shortened_text );
     352             :     }
     353           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     354             : 
     355           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX );
     356             : 
     357           6 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     358           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX );
     359             : 
     360           6 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     361             : 
     362           6 :     if ( out_err != U8_ERROR_NONE )
     363             :     {
     364           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     365           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     366             :     }
     367             : 
     368           6 :     U8_TRACE_END_ERR( result );
     369           6 :     return( result );
     370             : }
     371             : 
     372           5 : u8_error_t data_database_sql_builder_build_update_diagram_description_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagram_id, const char *new_diagram_description )
     373             : {
     374           5 :     U8_TRACE_BEGIN();
     375           5 :     assert( NULL != new_diagram_description );
     376           5 :     u8_error_t out_err = U8_ERROR_NONE;
     377           5 :     u8_error_t result = U8_ERROR_NONE;
     378             : 
     379           5 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     380             : 
     381           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX );
     382           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_DESCRIPTION );
     383             : 
     384           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     385           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     386             :     {
     387             :         /* prepare a shortened_text to */
     388             :         /* view the string but limited to the maximum allowed bytes: */
     389             :         utf8stringview_t shortened_text;
     390           5 :         const size_t new_length = utf8string_get_length( new_diagram_description );
     391           5 :         if ( new_length <= DATA_DIAGRAM_MAX_DESCRIPTION_LENGTH )
     392             :         {
     393           5 :             utf8stringview_init_str( &shortened_text, new_diagram_description );
     394             :         }
     395             :         else
     396             :         {
     397           0 :             out_err |= UTF8ERROR_TRUNCATED;
     398           0 :             utf8stringview_init( &shortened_text, new_diagram_description, DATA_DIAGRAM_MAX_DESCRIPTION_LENGTH );
     399             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
     400             :         }
     401           5 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
     402           5 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     403           5 :         utf8stringview_destroy( &shortened_text );
     404             :     }
     405           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     406             : 
     407           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX );
     408             : 
     409           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     410           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX );
     411             : 
     412           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     413             : 
     414           5 :     if ( out_err != U8_ERROR_NONE )
     415             :     {
     416           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     417           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     418             :     }
     419             : 
     420           5 :     U8_TRACE_END_ERR( result );
     421           5 :     return( result );
     422             : }
     423             : 
     424           9 : u8_error_t data_database_sql_builder_build_update_diagram_type_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagram_id, data_diagram_type_t new_diagram_type )
     425             : {
     426           9 :     U8_TRACE_BEGIN();
     427           9 :     u8_error_t out_err = U8_ERROR_NONE;
     428           9 :     u8_error_t result = U8_ERROR_NONE;
     429             : 
     430           9 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     431             : 
     432           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX );
     433           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_TYPE );
     434           9 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_diagram_type );
     435             : 
     436           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX );
     437             : 
     438           9 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     439           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX );
     440             : 
     441           9 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     442             : 
     443           9 :     if ( out_err != U8_ERROR_NONE )
     444             :     {
     445           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     446           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     447             :     }
     448             : 
     449           9 :     U8_TRACE_END_ERR( result );
     450           9 :     return( result );
     451             : }
     452             : 
     453           5 : u8_error_t data_database_sql_builder_build_update_diagram_list_order_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagram_id, int32_t new_diagram_list_order )
     454             : {
     455           5 :     U8_TRACE_BEGIN();
     456           5 :     u8_error_t out_err = U8_ERROR_NONE;
     457           5 :     u8_error_t result = U8_ERROR_NONE;
     458             : 
     459           5 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     460             : 
     461           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX );
     462           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_LIST_ORDER );
     463           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_diagram_list_order );
     464             : 
     465           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX );
     466             : 
     467           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     468           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX );
     469             : 
     470           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     471             : 
     472           5 :     if ( out_err != U8_ERROR_NONE )
     473             :     {
     474           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     475           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     476             :     }
     477             : 
     478           5 :     U8_TRACE_END_ERR( result );
     479           5 :     return( result );
     480             : }
     481             : 
     482           9 : u8_error_t data_database_sql_builder_build_update_diagram_parent_id_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagram_id, data_row_id_t new_diagram_parent_id )
     483             : {
     484           9 :     U8_TRACE_BEGIN();
     485           9 :     u8_error_t out_err = U8_ERROR_NONE;
     486           9 :     u8_error_t result = U8_ERROR_NONE;
     487             : 
     488           9 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     489             : 
     490           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_PREFIX );
     491           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_COL_PARENT_ID );
     492           9 :     if ( DATA_ROW_ID_VOID == new_diagram_parent_id )
     493             :     {
     494           4 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_NULL_VALUE );
     495             :     }
     496             :     else
     497             :     {
     498           5 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), new_diagram_parent_id );
     499             :     }
     500             : 
     501           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_INFIX );
     502             : 
     503           9 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagram_id );
     504           9 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAM_POSTFIX );
     505             : 
     506           9 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     507             : 
     508           9 :     if ( out_err != U8_ERROR_NONE )
     509             :     {
     510           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     511           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     512             :     }
     513             : 
     514           9 :     U8_TRACE_END_ERR( result );
     515           9 :     return( result );
     516             : }
     517             : 
     518             : /* ================================ CLASSIFIER ================================ */
     519             : 
     520             : /*!
     521             :  *  \brief prefix string constant to insert a classifier
     522             :  */
     523             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_CLASSIFIER_PREFIX =
     524             :     "INSERT INTO classifiers (main_type,stereotype,name,description,x_order,y_order,list_order,uuid) VALUES (";
     525             : 
     526             : /*!
     527             :  *  \brief prefix string constant to insert a classifier with predefined id
     528             :  */
     529             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_CLASSIFIER_WITH_ID_PREFIX =
     530             :     "INSERT INTO classifiers (id,main_type,stereotype,name,description,x_order,y_order,list_order,uuid) VALUES (";
     531             : 
     532             : /*!
     533             :  *  \brief postfix string constant to insert a classifier
     534             :  */
     535             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_CLASSIFIER_POSTFIX = ");";
     536             : 
     537             : /*!
     538             :  *  \brief prefix string constant to delete a classifier
     539             :  */
     540             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_CLASSIFIER_PREFIX =
     541             :     "DELETE FROM classifiers WHERE (id=";
     542             : 
     543             : /*!
     544             :  *  \brief postfix string constant to delete a classifier
     545             :  */
     546             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_CLASSIFIER_POSTFIX = ");";
     547             : 
     548             : /*!
     549             :  *  \brief prefix string constant to update a classifier
     550             :  */
     551             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX = "UPDATE classifiers SET ";
     552             : 
     553             : /*!
     554             :  *  \brief field name string constant to be used for updating a classifier
     555             :  */
     556             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_STEREOTYPE = "stereotype=";
     557             : 
     558             : /*!
     559             :  *  \brief field name string constant to be used for updating a classifier
     560             :  */
     561             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_MAIN_TYPE = "main_type=";
     562             : 
     563             : /*!
     564             :  *  \brief field name string constant to be used for updating a classifier
     565             :  */
     566             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_NAME = "name=";
     567             : 
     568             : /*!
     569             :  *  \brief field name string constant to be used for updating a classifier
     570             :  */
     571             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_DESCRIPTION = "description=";
     572             : 
     573             : /*!
     574             :  *  \brief field name string constant to be used for updating a classifier
     575             :  */
     576             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_X_ORDER = "x_order=";
     577             : 
     578             : /*!
     579             :  *  \brief field name string constant to be used for updating a classifier
     580             :  */
     581             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_Y_ORDER = "y_order=";
     582             : 
     583             : /*!
     584             :  *  \brief field name string constant to be used for updating a classifier
     585             :  */
     586             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_LIST_ORDER = "list_order=";
     587             : 
     588             : /*!
     589             :  *  \brief infix string constant to update a classifier
     590             :  */
     591             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX = " WHERE id=";
     592             : 
     593             : /*!
     594             :  *  \brief postfix string constant to update a classifier
     595             :  */
     596             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX = ";";
     597             : 
     598         223 : u8_error_t data_database_sql_builder_build_create_classifier_command ( data_database_sql_builder_t *this_, const data_classifier_t *classifier )
     599             : {
     600         223 :     U8_TRACE_BEGIN();
     601         223 :     assert( NULL != classifier );
     602         223 :     u8_error_t out_err = U8_ERROR_NONE;
     603         223 :     u8_error_t result = U8_ERROR_NONE;
     604             : 
     605         223 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     606             : 
     607         223 :     if ( data_classifier_get_row_id( classifier ) == DATA_ROW_ID_VOID )
     608             :     {
     609         183 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_CLASSIFIER_PREFIX );
     610             :     }
     611             :     else
     612             :     {
     613          40 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_CLASSIFIER_WITH_ID_PREFIX );
     614          40 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_classifier_get_row_id( classifier ) );
     615          40 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     616             :     }
     617         223 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_classifier_get_main_type( classifier ) );
     618         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     619             : 
     620         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     621         223 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     622         223 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_classifier_get_stereotype_const( classifier ) );
     623         223 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     624         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     625             : 
     626         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     627             : 
     628         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     629         223 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     630         223 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_classifier_get_name_const( classifier ) );
     631         223 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     632         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     633             : 
     634         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     635             : 
     636         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     637         223 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     638         223 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_classifier_get_description_const( classifier ) );
     639         223 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     640         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     641             : 
     642         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     643         223 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_classifier_get_x_order( classifier ) );
     644         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     645         223 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_classifier_get_y_order( classifier ) );
     646         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     647         223 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_classifier_get_list_order( classifier ) );
     648             : 
     649         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
     650             : 
     651         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     652         223 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     653         223 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_classifier_get_uuid_const( classifier ) );
     654         223 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     655         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     656             : 
     657         223 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_CLASSIFIER_POSTFIX );
     658             : 
     659         223 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     660             : 
     661         223 :     if ( out_err != U8_ERROR_NONE )
     662             :     {
     663           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     664           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     665             :     }
     666             : 
     667         223 :     U8_TRACE_END_ERR( result );
     668         223 :     return( result );
     669             : }
     670             : 
     671           4 : u8_error_t data_database_sql_builder_build_delete_classifier_command ( data_database_sql_builder_t *this_, data_row_id_t classifier_id )
     672             : {
     673           4 :     U8_TRACE_BEGIN();
     674           4 :     u8_error_t out_err = U8_ERROR_NONE;
     675           4 :     u8_error_t result = U8_ERROR_NONE;
     676             : 
     677           4 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     678             : 
     679           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_CLASSIFIER_PREFIX );
     680           4 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     681           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_CLASSIFIER_POSTFIX );
     682             : 
     683           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     684             : 
     685           4 :     if ( out_err != U8_ERROR_NONE )
     686             :     {
     687           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     688           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     689             :     }
     690             : 
     691           4 :     U8_TRACE_END_ERR( result );
     692           4 :     return( result );
     693             : }
     694             : 
     695           4 : u8_error_t data_database_sql_builder_build_update_classifier_stereotype_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, const char *new_classifier_stereotype )
     696             : {
     697           4 :     U8_TRACE_BEGIN();
     698           4 :     assert( NULL != new_classifier_stereotype );
     699           4 :     u8_error_t out_err = U8_ERROR_NONE;
     700           4 :     u8_error_t result = U8_ERROR_NONE;
     701             : 
     702           4 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     703             : 
     704           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     705           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_STEREOTYPE );
     706             : 
     707           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     708           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     709             :     {
     710             :         /* prepare a shortened_text to */
     711             :         /* view the string but limited to the maximum allowed bytes: */
     712             :         utf8stringview_t shortened_text;
     713           4 :         const size_t new_length = utf8string_get_length( new_classifier_stereotype );
     714           4 :         if ( new_length <= DATA_CLASSIFIER_MAX_STEREOTYPE_LENGTH )
     715             :         {
     716           4 :             utf8stringview_init_str( &shortened_text, new_classifier_stereotype );
     717             :         }
     718             :         else
     719             :         {
     720           0 :             out_err |= UTF8ERROR_TRUNCATED;
     721           0 :             utf8stringview_init( &shortened_text, new_classifier_stereotype, DATA_CLASSIFIER_MAX_STEREOTYPE_LENGTH );
     722             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
     723             :         }
     724           4 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
     725           4 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     726           4 :         utf8stringview_destroy( &shortened_text );
     727             :     }
     728           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     729             : 
     730           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     731             : 
     732           4 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     733           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     734             : 
     735           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     736             : 
     737           4 :     if ( out_err != U8_ERROR_NONE )
     738             :     {
     739           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     740           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     741             :     }
     742             : 
     743           4 :     U8_TRACE_END_ERR( result );
     744           4 :     return( result );
     745             : }
     746             : 
     747           3 : u8_error_t data_database_sql_builder_build_update_classifier_name_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, const char *new_classifier_name )
     748             : {
     749           3 :     U8_TRACE_BEGIN();
     750           3 :     assert( NULL != new_classifier_name );
     751           3 :     u8_error_t out_err = U8_ERROR_NONE;
     752           3 :     u8_error_t result = U8_ERROR_NONE;
     753             : 
     754           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     755             : 
     756           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     757           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_NAME );
     758             : 
     759           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     760           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     761             :     {
     762             :         /* prepare a shortened_text to */
     763             :         /* view the string but limited to the maximum allowed bytes: */
     764             :         utf8stringview_t shortened_text;
     765           3 :         const size_t new_length = utf8string_get_length( new_classifier_name );
     766           3 :         if ( new_length <= DATA_CLASSIFIER_MAX_NAME_LENGTH )
     767             :         {
     768           3 :             utf8stringview_init_str( &shortened_text, new_classifier_name );
     769             :         }
     770             :         else
     771             :         {
     772           0 :             out_err |= UTF8ERROR_TRUNCATED;
     773           0 :             utf8stringview_init( &shortened_text, new_classifier_name, DATA_CLASSIFIER_MAX_NAME_LENGTH );
     774             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
     775             :         }
     776           3 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
     777           3 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     778           3 :         utf8stringview_destroy( &shortened_text );
     779             :     }
     780           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     781             : 
     782           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     783             : 
     784           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     785           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     786             : 
     787           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     788             : 
     789           3 :     if ( out_err != U8_ERROR_NONE )
     790             :     {
     791           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     792           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     793             :     }
     794             : 
     795           3 :     U8_TRACE_END_ERR( result );
     796           3 :     return( result );
     797             : }
     798             : 
     799           3 : u8_error_t data_database_sql_builder_build_update_classifier_description_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, const char *new_classifier_description )
     800             : {
     801           3 :     U8_TRACE_BEGIN();
     802           3 :     assert( NULL != new_classifier_description );
     803           3 :     u8_error_t out_err = U8_ERROR_NONE;
     804           3 :     u8_error_t result = U8_ERROR_NONE;
     805             : 
     806           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     807             : 
     808           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     809           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_DESCRIPTION );
     810             : 
     811           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
     812           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
     813             :     {
     814             :         /* prepare a shortened_text to */
     815             :         /* view the string but limited to the maximum allowed bytes: */
     816             :         utf8stringview_t shortened_text;
     817           3 :         const size_t new_length = utf8string_get_length( new_classifier_description );
     818           3 :         if ( new_length <= DATA_CLASSIFIER_MAX_DESCRIPTION_LENGTH )
     819             :         {
     820           3 :             utf8stringview_init_str( &shortened_text, new_classifier_description );
     821             :         }
     822             :         else
     823             :         {
     824           0 :             out_err |= UTF8ERROR_TRUNCATED;
     825           0 :             utf8stringview_init( &shortened_text, new_classifier_description, DATA_CLASSIFIER_MAX_DESCRIPTION_LENGTH );
     826             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
     827             :         }
     828           3 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
     829           3 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
     830           3 :         utf8stringview_destroy( &shortened_text );
     831             :     }
     832           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
     833             : 
     834           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     835             : 
     836           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     837           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     838             : 
     839           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     840             : 
     841           3 :     if ( out_err != U8_ERROR_NONE )
     842             :     {
     843           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     844           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     845             :     }
     846             : 
     847           3 :     U8_TRACE_END_ERR( result );
     848           3 :     return( result );
     849             : }
     850             : 
     851           3 : u8_error_t data_database_sql_builder_build_update_classifier_main_type_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, data_classifier_type_t new_classifier_main_type )
     852             : {
     853           3 :     U8_TRACE_BEGIN();
     854           3 :     u8_error_t out_err = U8_ERROR_NONE;
     855           3 :     u8_error_t result = U8_ERROR_NONE;
     856             : 
     857           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     858             : 
     859           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     860           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_MAIN_TYPE );
     861             : 
     862           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_classifier_main_type );
     863             : 
     864           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     865             : 
     866           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     867           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     868             : 
     869           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     870             : 
     871           3 :     if ( out_err != U8_ERROR_NONE )
     872             :     {
     873           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     874           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     875             :     }
     876             : 
     877           3 :     U8_TRACE_END_ERR( result );
     878           3 :     return( result );
     879             : }
     880             : 
     881           3 : u8_error_t data_database_sql_builder_build_update_classifier_x_order_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, int32_t new_classifier_x_order )
     882             : {
     883           3 :     U8_TRACE_BEGIN();
     884           3 :     u8_error_t out_err = U8_ERROR_NONE;
     885           3 :     u8_error_t result = U8_ERROR_NONE;
     886             : 
     887           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     888             : 
     889           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     890           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_X_ORDER );
     891             : 
     892           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_classifier_x_order );
     893             : 
     894           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     895             : 
     896           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     897           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     898             : 
     899           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     900             : 
     901           3 :     if ( out_err != U8_ERROR_NONE )
     902             :     {
     903           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     904           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     905             :     }
     906             : 
     907           3 :     U8_TRACE_END_ERR( result );
     908           3 :     return( result );
     909             : }
     910             : 
     911           3 : u8_error_t data_database_sql_builder_build_update_classifier_y_order_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, int32_t new_classifier_y_order )
     912             : {
     913           3 :     U8_TRACE_BEGIN();
     914           3 :     u8_error_t out_err = U8_ERROR_NONE;
     915           3 :     u8_error_t result = U8_ERROR_NONE;
     916             : 
     917           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     918             : 
     919           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     920           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_Y_ORDER );
     921             : 
     922           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_classifier_y_order );
     923             : 
     924           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     925             : 
     926           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     927           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     928             : 
     929           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     930             : 
     931           3 :     if ( out_err != U8_ERROR_NONE )
     932             :     {
     933           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     934           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     935             :     }
     936             : 
     937           3 :     U8_TRACE_END_ERR( result );
     938           3 :     return( result );
     939             : }
     940             : 
     941           2 : u8_error_t data_database_sql_builder_build_update_classifier_list_order_cmd ( data_database_sql_builder_t *this_, data_row_id_t classifier_id, int32_t new_classifier_list_order )
     942             : {
     943           2 :     U8_TRACE_BEGIN();
     944           2 :     u8_error_t out_err = U8_ERROR_NONE;
     945           2 :     u8_error_t result = U8_ERROR_NONE;
     946             : 
     947           2 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
     948             : 
     949           2 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_PREFIX );
     950           2 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_COL_LIST_ORDER );
     951             : 
     952           2 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_classifier_list_order );
     953             : 
     954           2 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_INFIX );
     955             : 
     956           2 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), classifier_id );
     957           2 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_CLASSIFIER_POSTFIX );
     958             : 
     959           2 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
     960             : 
     961           2 :     if ( out_err != U8_ERROR_NONE )
     962             :     {
     963           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
     964           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
     965             :     }
     966             : 
     967           2 :     U8_TRACE_END_ERR( result );
     968           2 :     return( result );
     969             : }
     970             : 
     971             : /* ================================ DIAGRAMELEMENT ================================ */
     972             : 
     973             : /*!
     974             :  *  \brief prefix string constant to insert a diagramelement
     975             :  */
     976             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAMELEMENT_PREFIX =
     977             :     "INSERT INTO diagramelements (diagram_id,classifier_id,display_flags,focused_feature_id,uuid) VALUES (";
     978             : 
     979             : /*!
     980             :  *  \brief prefix string constant to insert a diagramelement with predefined id
     981             :  */
     982             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAMELEMENT_WITH_ID_PREFIX =
     983             :     "INSERT INTO diagramelements (id,diagram_id,classifier_id,display_flags,focused_feature_id,uuid) VALUES (";
     984             : 
     985             : /*!
     986             :  *  \brief postfix string constant to insert a diagramelement
     987             :  */
     988             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAMELEMENT_POSTFIX = ");";
     989             : 
     990             : /*!
     991             :  *  \brief prefix string constant to delete a diagramelement
     992             :  */
     993             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAMELEMENT_PREFIX =
     994             :     "DELETE FROM diagramelements WHERE (id=";
     995             : 
     996             : /*!
     997             :  *  \brief postfix string constant to delete a diagramelement
     998             :  */
     999             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAMELEMENT_POSTFIX = ");";
    1000             : 
    1001             : /*!
    1002             :  *  \brief prefix string constant to update a diagramelement
    1003             :  */
    1004             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_PREFIX = "UPDATE diagramelements SET ";
    1005             : 
    1006             : /*!
    1007             :  *  \brief field name string constant to be used for updating a diagramelement
    1008             :  */
    1009             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_COL_DISPLAY_FLAGS = "display_flags=";
    1010             : 
    1011             : /*!
    1012             :  *  \brief field name string constant to be used for updating a diagramelement
    1013             :  */
    1014             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_COL_FOCUSED_FEATURE_ID = "focused_feature_id=";
    1015             : 
    1016             : /*!
    1017             :  *  \brief infix string constant to update a diagramelement
    1018             :  */
    1019             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_INFIX = " WHERE id=";
    1020             : 
    1021             : /*!
    1022             :  *  \brief postfix string constant to update a diagramelement
    1023             :  */
    1024             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_POSTFIX = ";";
    1025             : 
    1026         237 : u8_error_t data_database_sql_builder_build_create_diagramelement_command ( data_database_sql_builder_t *this_, const data_diagramelement_t *diagramelement )
    1027             : {
    1028         237 :     U8_TRACE_BEGIN();
    1029         237 :     assert( NULL != diagramelement );
    1030         237 :     u8_error_t out_err = U8_ERROR_NONE;
    1031         237 :     u8_error_t result = U8_ERROR_NONE;
    1032             : 
    1033         237 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1034             : 
    1035         237 :     if ( DATA_ROW_ID_VOID == data_diagramelement_get_row_id( diagramelement ) )
    1036             :     {
    1037         195 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAMELEMENT_PREFIX );
    1038             :     }
    1039             :     else
    1040             :     {
    1041          42 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAMELEMENT_WITH_ID_PREFIX );
    1042          42 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagramelement_get_row_id( diagramelement ) );
    1043          42 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1044             :     }
    1045         237 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagramelement_get_diagram_row_id( diagramelement ) );
    1046         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1047         237 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagramelement_get_classifier_row_id( diagramelement ) );
    1048         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1049         237 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagramelement_get_display_flags( diagramelement ) );
    1050         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1051         237 :     if ( DATA_ROW_ID_VOID == data_diagramelement_get_focused_feature_row_id( diagramelement ) )
    1052             :     {
    1053         227 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_NULL_VALUE );
    1054             :     }
    1055             :     else
    1056             :     {
    1057          10 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_diagramelement_get_focused_feature_row_id( diagramelement ) );
    1058             :     }
    1059         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1060             : 
    1061         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1062         237 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1063         237 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_diagramelement_get_uuid_const( diagramelement ) );
    1064         237 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1065         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1066             : 
    1067         237 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_DIAGRAMELEMENT_POSTFIX );
    1068             : 
    1069         237 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1070             : 
    1071         237 :     if ( out_err != U8_ERROR_NONE )
    1072             :     {
    1073           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1074           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1075             :     }
    1076             : 
    1077         237 :     U8_TRACE_END_ERR( result );
    1078         237 :     return( result );
    1079             : }
    1080             : 
    1081          10 : u8_error_t data_database_sql_builder_build_delete_diagramelement_command ( data_database_sql_builder_t *this_, data_row_id_t diagramelement_id )
    1082             : {
    1083          10 :     U8_TRACE_BEGIN();
    1084          10 :     u8_error_t out_err = U8_ERROR_NONE;
    1085          10 :     u8_error_t result = U8_ERROR_NONE;
    1086             : 
    1087          10 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1088             : 
    1089          10 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAMELEMENT_PREFIX );
    1090          10 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagramelement_id );
    1091          10 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_DIAGRAMELEMENT_POSTFIX );
    1092             : 
    1093          10 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1094             : 
    1095          10 :     if ( out_err != U8_ERROR_NONE )
    1096             :     {
    1097           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1098           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1099             :     }
    1100             : 
    1101          10 :     U8_TRACE_END_ERR( result );
    1102          10 :     return( result );
    1103             : }
    1104             : 
    1105           6 : u8_error_t data_database_sql_builder_build_update_diagramelement_display_flags_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagramelement_id, data_diagramelement_flag_t new_display_flags )
    1106             : {
    1107           6 :     U8_TRACE_BEGIN();
    1108           6 :     u8_error_t out_err = U8_ERROR_NONE;
    1109           6 :     u8_error_t result = U8_ERROR_NONE;
    1110             : 
    1111           6 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1112             : 
    1113           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_PREFIX );
    1114           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_COL_DISPLAY_FLAGS );
    1115             : 
    1116           6 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_display_flags );
    1117             : 
    1118           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_INFIX );
    1119             : 
    1120           6 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagramelement_id );
    1121           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_POSTFIX );
    1122             : 
    1123           6 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1124             : 
    1125           6 :     if ( out_err != U8_ERROR_NONE )
    1126             :     {
    1127           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1128           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1129             :     }
    1130             : 
    1131           6 :     U8_TRACE_END_ERR( result );
    1132           6 :     return( result );
    1133             : }
    1134             : 
    1135          28 : u8_error_t data_database_sql_builder_build_update_diagramelement_focused_feature_id_cmd ( data_database_sql_builder_t *this_, data_row_id_t diagramelement_id, data_row_id_t new_focused_feature_id )
    1136             : {
    1137          28 :     U8_TRACE_BEGIN();
    1138          28 :     u8_error_t out_err = U8_ERROR_NONE;
    1139          28 :     u8_error_t result = U8_ERROR_NONE;
    1140             : 
    1141          28 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1142             : 
    1143          28 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_PREFIX );
    1144          28 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_COL_FOCUSED_FEATURE_ID );
    1145             : 
    1146          28 :     if ( DATA_ROW_ID_VOID == new_focused_feature_id )
    1147             :     {
    1148           6 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_NULL_VALUE );
    1149             :     }
    1150             :     else
    1151             :     {
    1152          22 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), new_focused_feature_id );
    1153             :     }
    1154             : 
    1155          28 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_INFIX );
    1156             : 
    1157          28 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), diagramelement_id );
    1158          28 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_DIAGRAMELEMENT_POSTFIX );
    1159             : 
    1160          28 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1161             : 
    1162          28 :     if ( out_err != U8_ERROR_NONE )
    1163             :     {
    1164           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1165           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1166             :     }
    1167             : 
    1168          28 :     U8_TRACE_END_ERR( result );
    1169          28 :     return( result );
    1170             : }
    1171             : 
    1172             : /* ================================ FEATURE ================================ */
    1173             : 
    1174             : /*!
    1175             :  *  \brief prefix string constant to insert a feature
    1176             :  */
    1177             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_FEATURE_PREFIX =
    1178             :     "INSERT INTO features (main_type,classifier_id,key,value,description,list_order,uuid) VALUES (";
    1179             : 
    1180             : /*!
    1181             :  *  \brief prefix string constant to insert a feature with predefined id
    1182             :  */
    1183             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_FEATURE_WITH_ID_PREFIX =
    1184             :     "INSERT INTO features (id,main_type,classifier_id,key,value,description,list_order,uuid) VALUES (";
    1185             : 
    1186             : /*!
    1187             :  *  \brief postfix string constant to insert a feature
    1188             :  */
    1189             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_FEATURE_POSTFIX = ");";
    1190             : 
    1191             : /*!
    1192             :  *  \brief prefix string constant to delete a feature
    1193             :  */
    1194             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_FEATURE_PREFIX =
    1195             :     "DELETE FROM features WHERE (id=";
    1196             : 
    1197             : /*!
    1198             :  *  \brief postfix string constant to delete a feature
    1199             :  */
    1200             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_FEATURE_POSTFIX = ");";
    1201             : 
    1202             : /*!
    1203             :  *  \brief prefix string constant to update a feature
    1204             :  */
    1205             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_PREFIX = "UPDATE features SET ";
    1206             : 
    1207             : /*!
    1208             :  *  \brief field name string constant to be used for updating a feature
    1209             :  */
    1210             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_MAIN_TYPE = "main_type=";
    1211             : 
    1212             : /*!
    1213             :  *  \brief field name string constant to be used for updating a feature
    1214             :  */
    1215             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_KEY = "key=";
    1216             : 
    1217             : /*!
    1218             :  *  \brief field name string constant to be used for updating a feature
    1219             :  */
    1220             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_VALUE = "value=";
    1221             : 
    1222             : /*!
    1223             :  *  \brief field name string constant to be used for updating a feature
    1224             :  */
    1225             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_DESCRIPTION = "description=";
    1226             : 
    1227             : /*!
    1228             :  *  \brief field name string constant to be used for updating a feature
    1229             :  */
    1230             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_LIST_ORDER = "list_order=";
    1231             : 
    1232             : /*!
    1233             :  *  \brief infix string constant to update a feature
    1234             :  */
    1235             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_INFIX = " WHERE id=";
    1236             : 
    1237             : /*!
    1238             :  *  \brief postfix string constant to update a feature
    1239             :  */
    1240             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_POSTFIX = ";";
    1241             : 
    1242         388 : u8_error_t data_database_sql_builder_build_create_feature_command ( data_database_sql_builder_t *this_, const data_feature_t *feature )
    1243             : {
    1244         388 :     U8_TRACE_BEGIN();
    1245         388 :     assert( NULL != feature );
    1246         388 :     u8_error_t out_err = U8_ERROR_NONE;
    1247         388 :     u8_error_t result = U8_ERROR_NONE;
    1248             : 
    1249         388 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1250             : 
    1251         388 :     if ( data_feature_get_row_id( feature ) == DATA_ROW_ID_VOID )
    1252             :     {
    1253         350 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_FEATURE_PREFIX );
    1254             :     }
    1255             :     else
    1256             :     {
    1257          38 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_FEATURE_WITH_ID_PREFIX );
    1258          38 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_feature_get_row_id( feature ) );
    1259          38 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1260             :     }
    1261         388 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_feature_get_main_type( feature ) );
    1262         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1263         388 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_feature_get_classifier_row_id( feature ) );
    1264         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1265             : 
    1266         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1267         388 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1268         388 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_feature_get_key_const( feature ) );
    1269         388 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1270         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1271             : 
    1272         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1273             : 
    1274         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1275         388 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1276         388 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_feature_get_value_const( feature ) );
    1277         388 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1278         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1279             : 
    1280         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1281             : 
    1282         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1283         388 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1284         388 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_feature_get_description_const( feature ) );
    1285         388 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1286         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1287             : 
    1288         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1289         388 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_feature_get_list_order( feature ) );
    1290             : 
    1291         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1292             : 
    1293         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1294         388 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1295         388 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_feature_get_uuid_const( feature ) );
    1296         388 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1297         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1298             : 
    1299         388 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_FEATURE_POSTFIX );
    1300             : 
    1301         388 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1302             : 
    1303         388 :     if ( out_err != U8_ERROR_NONE )
    1304             :     {
    1305           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1306           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1307             :     }
    1308             : 
    1309         388 :     U8_TRACE_END_ERR( result );
    1310         388 :     return( result );
    1311             : }
    1312             : 
    1313          14 : u8_error_t data_database_sql_builder_build_delete_feature_command ( data_database_sql_builder_t *this_, data_row_id_t feature_id )
    1314             : {
    1315          14 :     U8_TRACE_BEGIN();
    1316          14 :     u8_error_t out_err = U8_ERROR_NONE;
    1317          14 :     u8_error_t result = U8_ERROR_NONE;
    1318             : 
    1319          14 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1320             : 
    1321          14 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_FEATURE_PREFIX );
    1322          14 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), feature_id );
    1323          14 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_FEATURE_POSTFIX );
    1324             : 
    1325          14 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1326             : 
    1327          14 :     if ( out_err != U8_ERROR_NONE )
    1328             :     {
    1329           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1330           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1331             :     }
    1332             : 
    1333          14 :     U8_TRACE_END_ERR( result );
    1334          14 :     return( result );
    1335             : }
    1336             : 
    1337           6 : u8_error_t data_database_sql_builder_build_update_feature_main_type_cmd ( data_database_sql_builder_t *this_, data_row_id_t feature_id, data_feature_type_t new_feature_type )
    1338             : {
    1339           6 :     U8_TRACE_BEGIN();
    1340           6 :     u8_error_t out_err = U8_ERROR_NONE;
    1341           6 :     u8_error_t result = U8_ERROR_NONE;
    1342             : 
    1343           6 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1344             : 
    1345           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_PREFIX );
    1346           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_MAIN_TYPE );
    1347             : 
    1348           6 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_feature_type );
    1349             : 
    1350           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_INFIX );
    1351             : 
    1352           6 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), feature_id );
    1353           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_POSTFIX );
    1354             : 
    1355           6 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1356             : 
    1357           6 :     if ( out_err != U8_ERROR_NONE )
    1358             :     {
    1359           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1360           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1361             :     }
    1362             : 
    1363           6 :     U8_TRACE_END_ERR( result );
    1364           6 :     return( result );
    1365             : }
    1366             : 
    1367           5 : u8_error_t data_database_sql_builder_build_update_feature_key_cmd ( data_database_sql_builder_t *this_, data_row_id_t feature_id, const char *new_feature_key )
    1368             : {
    1369           5 :     U8_TRACE_BEGIN();
    1370           5 :     assert( NULL != new_feature_key );
    1371           5 :     u8_error_t out_err = U8_ERROR_NONE;
    1372           5 :     u8_error_t result = U8_ERROR_NONE;
    1373             : 
    1374           5 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1375             : 
    1376           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_PREFIX );
    1377           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_KEY );
    1378             : 
    1379           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1380           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1381             :     {
    1382             :         /* prepare a shortened_text to */
    1383             :         /* view the string but limited to the maximum allowed bytes: */
    1384             :         utf8stringview_t shortened_text;
    1385           5 :         const size_t new_length = utf8string_get_length( new_feature_key );
    1386           5 :         if ( new_length <= DATA_FEATURE_MAX_KEY_LENGTH )
    1387             :         {
    1388           5 :             utf8stringview_init_str( &shortened_text, new_feature_key );
    1389             :         }
    1390             :         else
    1391             :         {
    1392           0 :             out_err |= UTF8ERROR_TRUNCATED;
    1393           0 :             utf8stringview_init( &shortened_text, new_feature_key, DATA_FEATURE_MAX_KEY_LENGTH );
    1394             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
    1395             :         }
    1396           5 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
    1397           5 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1398           5 :         utf8stringview_destroy( &shortened_text );
    1399             :     }
    1400           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1401             : 
    1402           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_INFIX );
    1403             : 
    1404           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), feature_id );
    1405           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_POSTFIX );
    1406             : 
    1407           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1408             : 
    1409           5 :     if ( out_err != U8_ERROR_NONE )
    1410             :     {
    1411           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1412           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1413             :     }
    1414             : 
    1415           5 :     U8_TRACE_END_ERR( result );
    1416           5 :     return( result );
    1417             : }
    1418             : 
    1419           6 : u8_error_t data_database_sql_builder_build_update_feature_value_cmd ( data_database_sql_builder_t *this_, data_row_id_t feature_id, const char *new_feature_value )
    1420             : {
    1421           6 :     U8_TRACE_BEGIN();
    1422           6 :     assert( NULL != new_feature_value );
    1423           6 :     u8_error_t out_err = U8_ERROR_NONE;
    1424           6 :     u8_error_t result = U8_ERROR_NONE;
    1425             : 
    1426           6 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1427             : 
    1428           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_PREFIX );
    1429           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_VALUE );
    1430             : 
    1431           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1432           6 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1433             :     {
    1434             :         /* prepare a shortened_text to */
    1435             :         /* view the string but limited to the maximum allowed bytes: */
    1436             :         utf8stringview_t shortened_text;
    1437           6 :         const size_t new_length = utf8string_get_length( new_feature_value );
    1438           6 :         if ( new_length <= DATA_FEATURE_MAX_VALUE_LENGTH )
    1439             :         {
    1440           6 :             utf8stringview_init_str( &shortened_text, new_feature_value );
    1441             :         }
    1442             :         else
    1443             :         {
    1444           0 :             out_err |= UTF8ERROR_TRUNCATED;
    1445           0 :             utf8stringview_init( &shortened_text, new_feature_value, DATA_FEATURE_MAX_VALUE_LENGTH );
    1446             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
    1447             :         }
    1448           6 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
    1449           6 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1450           6 :         utf8stringview_destroy( &shortened_text );
    1451             :     }
    1452           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1453             : 
    1454           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_INFIX );
    1455             : 
    1456           6 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), feature_id );
    1457           6 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_POSTFIX );
    1458             : 
    1459           6 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1460             : 
    1461           6 :     if ( out_err != U8_ERROR_NONE )
    1462             :     {
    1463           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1464           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1465             :     }
    1466             : 
    1467           6 :     U8_TRACE_END_ERR( result );
    1468           6 :     return( result );
    1469             : }
    1470             : 
    1471           5 : u8_error_t data_database_sql_builder_build_update_feature_description_cmd ( data_database_sql_builder_t *this_, data_row_id_t feature_id, const char *new_feature_description )
    1472             : {
    1473           5 :     U8_TRACE_BEGIN();
    1474           5 :     assert( NULL != new_feature_description );
    1475           5 :     u8_error_t out_err = U8_ERROR_NONE;
    1476           5 :     u8_error_t result = U8_ERROR_NONE;
    1477             : 
    1478           5 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1479             : 
    1480           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_PREFIX );
    1481           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_DESCRIPTION );
    1482             : 
    1483           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1484           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1485             :     {
    1486             :         /* prepare a shortened_text to */
    1487             :         /* view the string but limited to the maximum allowed bytes: */
    1488             :         utf8stringview_t shortened_text;
    1489           5 :         const size_t new_length = utf8string_get_length( new_feature_description );
    1490           5 :         if ( new_length <= DATA_FEATURE_MAX_DESCRIPTION_LENGTH )
    1491             :         {
    1492           5 :             utf8stringview_init_str( &shortened_text, new_feature_description );
    1493             :         }
    1494             :         else
    1495             :         {
    1496           0 :             out_err |= UTF8ERROR_TRUNCATED;
    1497           0 :             utf8stringview_init( &shortened_text, new_feature_description, DATA_FEATURE_MAX_DESCRIPTION_LENGTH );
    1498             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
    1499             :         }
    1500           5 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
    1501           5 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1502           5 :         utf8stringview_destroy( &shortened_text );
    1503             :     }
    1504           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1505             : 
    1506           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_INFIX );
    1507             : 
    1508           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), feature_id );
    1509           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_POSTFIX );
    1510             : 
    1511           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1512             : 
    1513           5 :     if ( out_err != U8_ERROR_NONE )
    1514             :     {
    1515           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1516           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1517             :     }
    1518             : 
    1519           5 :     U8_TRACE_END_ERR( result );
    1520           5 :     return( result );
    1521             : }
    1522             : 
    1523           5 : u8_error_t data_database_sql_builder_build_update_feature_list_order_cmd ( data_database_sql_builder_t *this_, data_row_id_t feature_id, int32_t new_feature_list_order )
    1524             : {
    1525           5 :     U8_TRACE_BEGIN();
    1526           5 :     u8_error_t out_err = U8_ERROR_NONE;
    1527           5 :     u8_error_t result = U8_ERROR_NONE;
    1528             : 
    1529           5 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1530             : 
    1531           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_PREFIX );
    1532           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_COL_LIST_ORDER );
    1533             : 
    1534           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_feature_list_order );
    1535             : 
    1536           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_INFIX );
    1537             : 
    1538           5 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), feature_id );
    1539           5 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_FEATURE_POSTFIX );
    1540             : 
    1541           5 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1542             : 
    1543           5 :     if ( out_err != U8_ERROR_NONE )
    1544             :     {
    1545           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1546           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1547             :     }
    1548             : 
    1549           5 :     U8_TRACE_END_ERR( result );
    1550           5 :     return( result );
    1551             : }
    1552             : 
    1553             : /* ================================ RELATIONSHIP ================================ */
    1554             : 
    1555             : /*!
    1556             :  *  \brief prefix string constant to insert a relationship
    1557             :  */
    1558             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_RELATIONSHIP_PREFIX =
    1559             :     "INSERT INTO relationships "
    1560             :     "(main_type,from_classifier_id,to_classifier_id,stereotype,name,description,list_order,from_feature_id,to_feature_id,uuid) "
    1561             :     "VALUES (";
    1562             : 
    1563             : /*!
    1564             :  *  \brief prefix string constant to insert a relationship with predefined id
    1565             :  */
    1566             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_RELATIONSHIP_WITH_ID_PREFIX =
    1567             :     "INSERT INTO relationships "
    1568             :     "(id,main_type,from_classifier_id,to_classifier_id,stereotype,name,description,list_order,from_feature_id,to_feature_id,uuid) "
    1569             :     "VALUES (";
    1570             : 
    1571             : /*!
    1572             :  *  \brief postfix string constant to insert a relationship
    1573             :  */
    1574             : static const char *DATA_DATABASE_SQL_BUILDER_INSERT_RELATIONSHIP_POSTFIX = ");";
    1575             : 
    1576             : /*!
    1577             :  *  \brief prefix string constant to delete a relationship
    1578             :  */
    1579             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_RELATIONSHIP_PREFIX =
    1580             :     "DELETE FROM relationships WHERE (id=";
    1581             : 
    1582             : /*!
    1583             :  *  \brief postfix string constant to delete a relationship
    1584             :  */
    1585             : static const char *DATA_DATABASE_SQL_BUILDER_DELETE_RELATIONSHIP_POSTFIX = ");";
    1586             : 
    1587             : /*!
    1588             :  *  \brief prefix string constant to update a relationship
    1589             :  */
    1590             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_PREFIX = "UPDATE relationships SET ";
    1591             : 
    1592             : /*!
    1593             :  *  \brief field name string constant to be used for updating a relationship
    1594             :  */
    1595             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_MAIN_TYPE = "main_type=";
    1596             : 
    1597             : /*!
    1598             :  *  \brief field name string constant to be used for updating a relationship
    1599             :  */
    1600             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_STEREOTYPE = "stereotype=";
    1601             : 
    1602             : /*!
    1603             :  *  \brief field name string constant to be used for updating a relationship
    1604             :  */
    1605             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_NAME = "name=";
    1606             : 
    1607             : /*!
    1608             :  *  \brief field name string constant to be used for updating a relationship
    1609             :  */
    1610             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_DESCRIPTION = "description=";
    1611             : 
    1612             : /*!
    1613             :  *  \brief field name string constant to be used for updating a relationship
    1614             :  */
    1615             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_LIST_ORDER = "list_order=";
    1616             : 
    1617             : /*!
    1618             :  *  \brief infix string constant to update a relationship
    1619             :  */
    1620             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_INFIX = " WHERE id=";
    1621             : 
    1622             : /*!
    1623             :  *  \brief postfix string constant to update a relationship
    1624             :  */
    1625             : static const char *DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_POSTFIX = ";";
    1626             : 
    1627        1327 : u8_error_t data_database_sql_builder_build_create_relationship_command ( data_database_sql_builder_t *this_, const data_relationship_t *relationship )
    1628             : {
    1629        1327 :     U8_TRACE_BEGIN();
    1630        1327 :     assert( NULL != relationship );
    1631        1327 :     u8_error_t out_err = U8_ERROR_NONE;
    1632        1327 :     u8_error_t result = U8_ERROR_NONE;
    1633             : 
    1634        1327 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1635             : 
    1636        1327 :     if ( data_relationship_get_row_id( relationship ) == DATA_ROW_ID_VOID )
    1637             :     {
    1638        1295 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_RELATIONSHIP_PREFIX );
    1639             :     }
    1640             :     else
    1641             :     {
    1642          32 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_RELATIONSHIP_WITH_ID_PREFIX );
    1643          32 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_row_id( relationship ) );
    1644          32 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1645             :     }
    1646        1327 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_main_type( relationship ) );
    1647        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1648        1327 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_from_classifier_row_id( relationship ) );
    1649        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1650        1327 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_to_classifier_row_id( relationship ) );
    1651        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1652             : 
    1653             :     /* stereotype */
    1654        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1655        1327 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1656        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_relationship_get_stereotype_const( relationship ) );
    1657        1327 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1658        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1659             : 
    1660        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1661             : 
    1662             :     /* name */
    1663        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1664        1327 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1665        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_relationship_get_name_const( relationship ) );
    1666        1327 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1667        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1668             : 
    1669        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1670             : 
    1671             :     /* description*/
    1672        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1673        1327 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1674        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_relationship_get_description_const( relationship ) );
    1675        1327 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1676        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1677             : 
    1678        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1679        1327 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_list_order( relationship ) );
    1680        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1681             : 
    1682        1327 :     if ( DATA_ROW_ID_VOID == data_relationship_get_from_feature_row_id( relationship ) )
    1683             :     {
    1684        1307 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_NULL_VALUE );
    1685             :     }
    1686             :     else
    1687             :     {
    1688          20 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_from_feature_row_id( relationship ) );
    1689             :     }
    1690        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1691        1327 :     if ( DATA_ROW_ID_VOID == data_relationship_get_to_feature_row_id( relationship ) )
    1692             :     {
    1693        1304 :         out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_NULL_VALUE );
    1694             :     }
    1695             :     else
    1696             :     {
    1697          23 :         out_err |= utf8stream_writer_write_int( &((*this_).plain), data_relationship_get_to_feature_row_id( relationship ) );
    1698             :     }
    1699             : 
    1700        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_VALUE_SEPARATOR );
    1701             : 
    1702        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1703        1327 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1704        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).escaped), data_relationship_get_uuid_const( relationship ) );
    1705        1327 :     out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1706        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1707             : 
    1708        1327 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_INSERT_RELATIONSHIP_POSTFIX );
    1709             : 
    1710        1327 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1711             : 
    1712        1327 :     if ( out_err != U8_ERROR_NONE )
    1713             :     {
    1714           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1715           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1716             :     }
    1717             : 
    1718        1327 :     U8_TRACE_END_ERR( result );
    1719        1327 :     return( result );
    1720             : }
    1721             : 
    1722          15 : u8_error_t data_database_sql_builder_build_delete_relationship_command ( data_database_sql_builder_t *this_, data_row_id_t relationship_id )
    1723             : {
    1724          15 :     U8_TRACE_BEGIN();
    1725          15 :     u8_error_t out_err = U8_ERROR_NONE;
    1726          15 :     u8_error_t result = U8_ERROR_NONE;
    1727             : 
    1728          15 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1729             : 
    1730          15 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_RELATIONSHIP_PREFIX );
    1731          15 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), relationship_id );
    1732          15 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_DELETE_RELATIONSHIP_POSTFIX );
    1733             : 
    1734          15 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1735             : 
    1736          15 :     if ( out_err != U8_ERROR_NONE )
    1737             :     {
    1738           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1739           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1740             :     }
    1741             : 
    1742          15 :     U8_TRACE_END_ERR( result );
    1743          15 :     return( result );
    1744             : }
    1745             : 
    1746           3 : u8_error_t data_database_sql_builder_build_update_relationship_main_type_cmd ( data_database_sql_builder_t *this_, data_row_id_t relationship_id, data_relationship_type_t new_relationship_type )
    1747             : {
    1748           3 :     U8_TRACE_BEGIN();
    1749           3 :     u8_error_t out_err = U8_ERROR_NONE;
    1750           3 :     u8_error_t result = U8_ERROR_NONE;
    1751             : 
    1752           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1753             : 
    1754           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_PREFIX );
    1755           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_MAIN_TYPE );
    1756             : 
    1757           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_relationship_type );
    1758             : 
    1759           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_INFIX );
    1760             : 
    1761           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), relationship_id );
    1762           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_POSTFIX );
    1763             : 
    1764           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1765             : 
    1766           3 :     if ( out_err != U8_ERROR_NONE )
    1767             :     {
    1768           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1769           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1770             :     }
    1771             : 
    1772           3 :     U8_TRACE_END_ERR( result );
    1773           3 :     return( result );
    1774             : }
    1775             : 
    1776           3 : u8_error_t data_database_sql_builder_build_update_relationship_stereotype_cmd ( data_database_sql_builder_t *this_,
    1777             :                                                                                 data_row_id_t relationship_id,
    1778             :                                                                                 const char *new_relationship_stereotype )
    1779             : {
    1780             : 
    1781           3 :     U8_TRACE_BEGIN();
    1782           3 :     assert( NULL != new_relationship_stereotype );
    1783           3 :     u8_error_t out_err = U8_ERROR_NONE;
    1784           3 :     u8_error_t result = U8_ERROR_NONE;
    1785             : 
    1786           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1787             : 
    1788           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_PREFIX );
    1789           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_STEREOTYPE );
    1790             : 
    1791           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1792           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1793             :     {
    1794             :         /* prepare a shortened_text to */
    1795             :         /* view the string but limited to the maximum allowed bytes: */
    1796             :         utf8stringview_t shortened_text;
    1797           3 :         const size_t new_length = utf8string_get_length( new_relationship_stereotype );
    1798           3 :         if ( new_length <= DATA_RELATIONSHIP_MAX_STEREOTYPE_LENGTH )
    1799             :         {
    1800           3 :             utf8stringview_init_str( &shortened_text, new_relationship_stereotype );
    1801             :         }
    1802             :         else
    1803             :         {
    1804           0 :             out_err |= UTF8ERROR_TRUNCATED;
    1805           0 :             utf8stringview_init( &shortened_text, new_relationship_stereotype, DATA_RELATIONSHIP_MAX_STEREOTYPE_LENGTH );
    1806             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
    1807             :         }
    1808           3 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
    1809           3 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1810           3 :         utf8stringview_destroy( &shortened_text );
    1811             :     }
    1812           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1813             : 
    1814           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_INFIX );
    1815             : 
    1816           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), relationship_id );
    1817           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_POSTFIX );
    1818             : 
    1819           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1820             : 
    1821           3 :     if ( out_err != U8_ERROR_NONE )
    1822             :     {
    1823           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1824           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1825             :     }
    1826             : 
    1827           3 :     U8_TRACE_END_ERR( result );
    1828           3 :     return( result );
    1829             : }
    1830             : 
    1831           3 : u8_error_t data_database_sql_builder_build_update_relationship_name_cmd ( data_database_sql_builder_t *this_,
    1832             :                                                                           data_row_id_t relationship_id,
    1833             :                                                                           const char *new_relationship_name )
    1834             : {
    1835           3 :     U8_TRACE_BEGIN();
    1836           3 :     assert( NULL != new_relationship_name );
    1837           3 :     u8_error_t out_err = U8_ERROR_NONE;
    1838           3 :     u8_error_t result = U8_ERROR_NONE;
    1839             : 
    1840           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1841             : 
    1842           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_PREFIX );
    1843           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_NAME );
    1844             : 
    1845           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1846           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1847             :     {
    1848             :         /* prepare a shortened_text to */
    1849             :         /* view the string but limited to the maximum allowed bytes: */
    1850             :         utf8stringview_t shortened_text;
    1851           3 :         const size_t new_length = utf8string_get_length( new_relationship_name );
    1852           3 :         if ( new_length <= DATA_RELATIONSHIP_MAX_NAME_LENGTH )
    1853             :         {
    1854           3 :             utf8stringview_init_str( &shortened_text, new_relationship_name );
    1855             :         }
    1856             :         else
    1857             :         {
    1858           0 :             out_err |= UTF8ERROR_TRUNCATED;
    1859           0 :             utf8stringview_init( &shortened_text, new_relationship_name, DATA_RELATIONSHIP_MAX_NAME_LENGTH );
    1860             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
    1861             :         }
    1862           3 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
    1863           3 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1864           3 :         utf8stringview_destroy( &shortened_text );
    1865             :     }
    1866           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1867             : 
    1868           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_INFIX );
    1869             : 
    1870           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), relationship_id );
    1871           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_POSTFIX );
    1872             : 
    1873           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1874             : 
    1875           3 :     if ( out_err != U8_ERROR_NONE )
    1876             :     {
    1877           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1878           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1879             :     }
    1880             : 
    1881           3 :     U8_TRACE_END_ERR( result );
    1882           3 :     return( result );
    1883             : }
    1884             : 
    1885           4 : u8_error_t data_database_sql_builder_build_update_relationship_description_cmd ( data_database_sql_builder_t *this_, data_row_id_t relationship_id, const char *new_relationship_description )
    1886             : {
    1887           4 :     U8_TRACE_BEGIN();
    1888           4 :     assert( NULL != new_relationship_description );
    1889           4 :     u8_error_t out_err = U8_ERROR_NONE;
    1890           4 :     u8_error_t result = U8_ERROR_NONE;
    1891             : 
    1892           4 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1893             : 
    1894           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_PREFIX );
    1895           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_DESCRIPTION );
    1896             : 
    1897           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_START );
    1898           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );
    1899             :     {
    1900             :         /* prepare a shortened_text to */
    1901             :         /* view the string but limited to the maximum allowed bytes: */
    1902             :         utf8stringview_t shortened_text;
    1903           4 :         const size_t new_length = utf8string_get_length( new_relationship_description );
    1904           4 :         if ( new_length <= DATA_RELATIONSHIP_MAX_DESCRIPTION_LENGTH )
    1905             :         {
    1906           4 :             utf8stringview_init_str( &shortened_text, new_relationship_description );
    1907             :         }
    1908             :         else
    1909             :         {
    1910           0 :             out_err |= UTF8ERROR_TRUNCATED;
    1911           0 :             utf8stringview_init( &shortened_text, new_relationship_description, DATA_RELATIONSHIP_MAX_DESCRIPTION_LENGTH );
    1912             :             /* ignore a possible UTF8ERROR_OUT_OF_RANGE result */
    1913             :         }
    1914           4 :         out_err |= utf8stream_writer_write_view( &((*this_).escaped), &shortened_text );
    1915           4 :         out_err |= utf8stream_writer_flush( &((*this_).escaped) );
    1916           4 :         utf8stringview_destroy( &shortened_text );
    1917             :     }
    1918           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_STRING_VALUE_END );
    1919             : 
    1920           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_INFIX );
    1921             : 
    1922           4 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), relationship_id );
    1923           4 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_POSTFIX );
    1924             : 
    1925           4 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1926             : 
    1927           4 :     if ( out_err != U8_ERROR_NONE )
    1928             :     {
    1929           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1930           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1931             :     }
    1932             : 
    1933           4 :     U8_TRACE_END_ERR( result );
    1934           4 :     return( result );
    1935             : }
    1936             : 
    1937           3 : u8_error_t data_database_sql_builder_build_update_relationship_list_order_cmd ( data_database_sql_builder_t *this_, data_row_id_t relationship_id, int32_t new_relationship_list_order )
    1938             : {
    1939           3 :     U8_TRACE_BEGIN();
    1940           3 :     u8_error_t out_err = U8_ERROR_NONE;
    1941           3 :     u8_error_t result = U8_ERROR_NONE;
    1942             : 
    1943           3 :     out_err |= universal_memory_output_stream_reset( &((*this_).plain_out) );
    1944             : 
    1945           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_PREFIX );
    1946           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_COL_LIST_ORDER );
    1947             : 
    1948           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), new_relationship_list_order );
    1949             : 
    1950           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_INFIX );
    1951             : 
    1952           3 :     out_err |= utf8stream_writer_write_int( &((*this_).plain), relationship_id );
    1953           3 :     out_err |= utf8stream_writer_write_str( &((*this_).plain), DATA_DATABASE_SQL_BUILDER_UPDATE_RELATIONSHIP_POSTFIX );
    1954             : 
    1955           3 :     out_err |= utf8stream_writer_flush( &((*this_).plain) );  /* enforces 0-termination on (*this_).plain_out */
    1956             : 
    1957           3 :     if ( out_err != U8_ERROR_NONE )
    1958             :     {
    1959           0 :         U8_LOG_ERROR_HEX( "utf8stream_writer_write_...() failed:", out_err );
    1960           0 :         result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
    1961             :     }
    1962             : 
    1963           3 :     U8_TRACE_END_ERR( result );
    1964           3 :     return( result );
    1965             : }
    1966             : 
    1967             : 
    1968             : /*
    1969             : Copyright 2016-2024 Andreas Warnke
    1970             : 
    1971             : Licensed under the Apache License, Version 2.0 (the "License");
    1972             : you may not use this file except in compliance with the License.
    1973             : You may obtain a copy of the License at
    1974             : 
    1975             :     http://www.apache.org/licenses/LICENSE-2.0
    1976             : 
    1977             : Unless required by applicable law or agreed to in writing, software
    1978             : distributed under the License is distributed on an "AS IS" BASIS,
    1979             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1980             : See the License for the specific language governing permissions and
    1981             : limitations under the License.
    1982             : */

Generated by: LCOV version 1.16