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

Method MakeViewColumns

storage/connect/tabpivot.cpp:583–630  ·  view source on GitHub ↗

/ Make the required pivot columns for an object view. */ /

Source from the content-addressed store, hash-verified

581/* Make the required pivot columns for an object view. */
582/***********************************************************************/
583bool TDBPIVOT::MakeViewColumns(PGLOBAL g)
584 {
585 if (Tdbp->IsView()) {
586 // Tdbp is a view ColDB cannot be used
587 PCOL colp, cp;
588 PTDBMY tdbp;
589
590 if (Tdbp->GetAmType() != TYPE_AM_MYSQL) {
591 snprintf(g->Message, sizeof(g->Message),"View is not MySQL");
592 return true;
593 } else
594 tdbp = (PTDBMY)Tdbp;
595
596 if (!Fncol && !(Fncol = tdbp->FindFieldColumn(Picol))) {
597 snprintf(g->Message, sizeof(g->Message), MSG(NO_DEF_FNCCOL));
598 return true;
599 } // endif Fncol
600
601 if (!Picol && !(Picol = tdbp->FindFieldColumn(Fncol))) {
602 snprintf(g->Message, sizeof(g->Message), MSG(NO_DEF_PIVOTCOL));
603 return true;
604 } // endif Picol
605
606 // Now it is time to allocate the pivot and function columns
607 if (!(Fcolp = tdbp->MakeFieldColumn(g, Fncol)))
608 return true;
609
610 if (!(Xcolp = tdbp->MakeFieldColumn(g, Picol)))
611 return true;
612
613 // Check and initialize the subtable columns
614 for (cp = Columns; cp; cp = cp->GetNext())
615 if (cp->GetAmType() == TYPE_AM_SRC) {
616 if ((colp = tdbp->MakeFieldColumn(g, cp->GetName()))) {
617 ((PSRCCOL)cp)->Colp = colp;
618 ((PSRCCOL)cp)->To_Val = colp->GetValue();
619 cp->AddStatus(BUF_READ); // All is done here
620 } else
621 return true;
622
623 } else if (cp->GetAmType() == TYPE_AM_FNC)
624 if (((PFNCCOL)cp)->InitColumn(g))
625 return TRUE;
626
627 } // endif isview
628
629 return false;
630 } // end of MakeViewColumns
631
632/***********************************************************************/
633/* PIVOT GetMaxSize: returns the maximum number of rows in the table. */

Callers

nothing calls this directly

Calls 8

FindFieldColumnMethod · 0.80
MakeFieldColumnMethod · 0.80
InitColumnMethod · 0.80
IsViewMethod · 0.45
GetAmTypeMethod · 0.45
GetNextMethod · 0.45
GetNameMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected