Extend the EET DML oracle to INSERT support - #1358
Conversation
Just a quick check: assuming that this is a workaround, could we just set the column list in the generator temporarily to be empty? Not sure if I understood the problem correctly. |
mrigger
left a comment
There was a problem hiding this comment.
LGTM! Just waiting for a response to the other comment I just posted before merging.
| @Override | ||
| public List<MySQLExpression> generateInsertValues() { | ||
| // One value per content column, in schema order (aligned with the INSERT column list). As with the normal | ||
| // INSERT workload, each value is an arbitrary expression (not type-matched to the column); any resulting |
There was a problem hiding this comment.
Ah, I wasn't aware or forgot that the INSERT generator is untyped. Probably, it should be typed, as it would make it much more likely to generate meaningful databases. But, I guess that's for another PR.
There was a problem hiding this comment.
Yes, FYI this isn't MySQL-specific, it is a similar story for most other weakly typed DBMSs
Yes, it is possible to implement |
The EET DML oracle (
EETDMLOracle) previously transformedDELETEandUPDATEstatements. This PR addsINSERTto the same oracle.The
INSERTis generated in theINSERT ... SELECTform rather thanINSERT ... VALUES. This is because, when a value expression is transformed, the transformer introduces equivalent sub-expressions that reference the table's columns (for example, the random predicate inside aCASE WHEN). Column references are legal in aSELECTbut not in aVALUESclause, so aVALUESform would produce invalid SQL without additional workarounds. Note, this does NOT mean that the testing is limited to only insert column references. It can still insert new constants too. For example,INSERT INTO t (c1) SELECT (123) FROM t WHERE pwould insertnrows with the constant123, wherenis the number of rows intwhich satisfyp. So, theINSERT ... SELECTform is expected to stress the DBMS at least as much as theINSERT ... VALUESform would.Because
INSERT ... SELECTinserts one new row per source row, each new row needs an identifier so the two runs' states can be lined up. Although the existing rows are originally stamped withUUID(), this cannot be used for the inserted rows, because it would be non-deterministic across the two runs. The implementation chosen here for MySQL simply removes the four dashes from the existing row's rowid, usingREPLACE(rowid, '-', ''). This is deterministic (both runs assign the same identifiers), unique per source row, and distinct from every existing identifier (a 32-character string never equals the 36-character source string). It also fits the existing identifier column without widening it.