/ Make the required pivot columns for an object view. */ /
| 581 | /* Make the required pivot columns for an object view. */ |
| 582 | /***********************************************************************/ |
| 583 | bool 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. */ |
nothing calls this directly
no test coverage detected