MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sql_dump_small

Function sql_dump_small

tests/test_pipeline.c:434–467  ·  view source on GitHub ↗

A small dump: two tables, a view, three INSERTs of 200 rows, each with one * subquery row and one function-call row among literal rows. */

Source from the content-addressed store, hash-verified

432/* A small dump: two tables, a view, three INSERTs of 200 rows, each with one
433 * subquery row and one function-call row among literal rows. */
434static char *sql_dump_small(bool mysql_esc) {
435 size_t cap = 256 * 1024;
436 char *src = malloc(cap);
437 if (!src) {
438 return NULL;
439 }
440 const char *quoted = mysql_esc ? "(%d,'O\\'Brien',DEFAULT)" : "(%d,'O''Brien',DEFAULT)";
441 size_t len = (size_t)snprintf(src, cap,
442 "CREATE TABLE city (ID int, Name char(35), Population int);\n"
443 "CREATE TABLE country (Code char(3), Name char(52));\n"
444 "CREATE VIEW big_cities AS SELECT Name FROM city "
445 "WHERE Population > 1000000;\n");
446 for (int s = 0; s < 3; s++) {
447 len += (size_t)snprintf(src + len, cap - len, "INSERT INTO `city` VALUES ");
448 for (int r = 0; r < 200; r++) {
449 if (r) {
450 src[len++] = ',';
451 }
452 int id = s * 1000 + r;
453 if (r == 100) {
454 len += (size_t)snprintf(src + len, cap - len,
455 "((SELECT MAX(Code) FROM country),'x',1)");
456 } else if (r == 101) {
457 len += (size_t)snprintf(src + len, cap - len, "(%d,UPPER('y'),2)", id);
458 } else if (r % 3) {
459 len += (size_t)snprintf(src + len, cap - len, quoted, id);
460 } else {
461 len += (size_t)snprintf(src + len, cap - len, "(%d,_binary 'ab',NULL)", id);
462 }
463 }
464 len += (size_t)snprintf(src + len, cap - len, ";\n");
465 }
466 return src;
467}
468
469/* #1735: leaving a dump's literal INSERT rows out of the parse must not change
470 * the graph. The same repository is indexed twice — once as shipped and once

Callers 1

test_pipeline.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected