MCPcopy Create free account
hub / github.com/MariaDB/server / MakeInsert

Method MakeInsert

storage/connect/tabmysql.cpp:590–670  ·  view source on GitHub ↗

/ MakeInsert: make the Insert statement used with MySQL connection. */ /

Source from the content-addressed store, hash-verified

588/* MakeInsert: make the Insert statement used with MySQL connection. */
589/***********************************************************************/
590bool TDBMYSQL::MakeInsert(PGLOBAL g)
591 {
592 const char *tk = "`";
593 uint len = 0;
594 bool oom, b = false;
595 PCOL colp;
596
597 if (Query)
598 return false; // already done
599
600 if (Prep) {
601#if !defined(MYSQL_PREPARED_STATEMENTS)
602 snprintf(g->Message, sizeof(g->Message), "Prepared statements not used (not supported)");
603 PushWarning(g, this);
604 Prep = false;
605#endif // !MYSQL_PREPARED_STATEMENTS
606 } // endif Prep
607
608 for (colp = Columns; colp; colp = colp->GetNext())
609 if (colp->IsSpecial()) {
610 snprintf(g->Message, sizeof(g->Message), MSG(NO_SPEC_COL));
611 return true;
612 } else {
613 len += (strlen(colp->GetName()) + 4);
614
615 // Parameter marker
616 if (!Prep) {
617 if (colp->GetResultType() == TYPE_DATE)
618 len += 20;
619 else
620 len += colp->GetLength();
621
622 } else
623 len += 2;
624
625 ((PMYCOL)colp)->Rank = Nparm++;
626 } // endif colp
627
628 // Below 40 is enough to contain the fixed part of the query
629 len += (strlen(TableName) + 40);
630 Query = new(g) STRING(g, len);
631
632 Query->Set("INSERT ");
633 if (Delayed)
634 Query->Append("DELAYED ");
635 if (Ignored)
636 Query->Append("IGNORE ");
637
638 Query->Append("INTO ");
639 Query->Append(tk);
640 Query->Append(TableName);
641 Query->Append("` (");
642
643 for (colp = Columns; colp; colp = colp->GetNext()) {
644 if (b)
645 Query->Append(", ");
646 else
647 b = true;

Callers

nothing calls this directly

Calls 7

PushWarningFunction · 0.85
IsSpecialMethod · 0.80
SetMethod · 0.80
AppendMethod · 0.80
GetNextMethod · 0.45
GetNameMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected