WL#13195: TABLE WITH JSON SCHEMA VALIDATION CONSTRAINT SHOULD RETURN ERROR FOR CONCRETE ROW

Affects: Server-8.0   —   Status: Complete

When check constraint is used for the JSON schema validation, if      
user tries to insert document which violates the check constraint then
constraint violation error "ER_CHECK_CONSTRAINT_VIOLATED - Check      
constraint 'constraint_name' is violated." is reported. But the       
reported error or diagnostic area does not contain information about 
the document and a issue.                                             
                                                                      
Goal of this WL is to report a SQL condition with information about   
the document and a issue on CHECK constraint (used for the JSON       
schema validation) violation.  

Current behavior on constraint violation:                             
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                             
  CREATE TABLE t1 (                                                   
  geometry JSON,                                                      
  CHECK(JSON_SCHEMA_VALID('{                                          
        "type": "object",                                             
        "properties": {                                               
          "latitude": {"type": "number", "minimum": -90,  "maximum": 90},
          "longitude": {"type": "number", "minimum": -180, "maximum": 180}
        }                                                             
      }', geometry)                                                   
  )                                                                   
  );                                                                  
                                                                      
  INSERT INTO t1 VALUES ('{"latitude": 181, "longitude": 0}');        
  ERROR HY000: Check constraint 't1_chk_1' is violated.               
                                                                      
  SHOW WARNINGS;                                                      
  Level Code    Message                                               
  Error 3819    Check constraint 't1_chk_1' is violated.

New behavior on constraint violation:                                 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                              
  INSERT INTO t1 VALUES ('{"latitude": 181, "longitude": 0}');          
  ERROR HY000: Check constraint 't1_chk_1' is violated.        
         
  SHOW WARNINGS;                                                        
  Level   Code    Message                                               
  Error   XXXX    The JSON document location '#/latitude'
                  failed requirement 'maximum' at JSON Schema location 
                  '#/properties/latitude'.
  Error   3819    Check constraint 't1_chk_1' is violated.

This WL will add a SQL condition in Diagnostics area with error code.
XXXX. XXXX will be a new error code introduced by this WL for detailed
information about the JSON schema validation error.