Example #1
0
bool TDBTBL::InitTableList(PGLOBAL g)
  {
  int     n;
  uint    sln;
  char   *scs;
  PTABLE  tp, tabp;
  PCOL    colp;
  PTBLDEF tdp = (PTBLDEF)To_Def;
  PCATLG  cat = To_Def->GetCat();
  PHC     hc = ((MYCAT*)cat)->GetHandler();

  scs = hc->get_table()->s->connect_string.str;
  sln = hc->get_table()->s->connect_string.length;
//  PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath());

  for (n = 0, tp = tdp->Tablep; tp; tp = tp->GetNext()) {
    if (TestFil(g, To_CondFil, tp)) {
      tabp = new(g) XTAB(tp);

      if (tabp->GetSrc()) {
        // Table list is a list of connections
        hc->get_table()->s->connect_string.str = (char*)tabp->GetName();
        hc->get_table()->s->connect_string.length = strlen(tabp->GetName());
        } // endif Src

      // Get the table description block of this table
      if (!(Tdbp = GetSubTable(g, tabp))) {
        if (++Nbc > Maxerr)
          return TRUE;               // Error return
        else
          continue;                  // Skip this table

      } else
        RemoveNext(tabp);            // To avoid looping

      // We must allocate subtable columns before GetMaxSize is called
      // because some (PLG, ODBC?) need to have their columns attached.
      // Real initialization will be done later.
      for (colp = Columns; colp; colp = colp->GetNext())
        if (!colp->IsSpecial())
          if (((PPRXCOL)colp)->Init(g, NULL) && !Accept)
            return TRUE;

      if (Tablist)
        Tablist->Link(tabp);
      else
        Tablist = tabp;

      n++;
      } // endif filp

    } // endfor tp

  hc->get_table()->s->connect_string.str = scs;
  hc->get_table()->s->connect_string.length = sln;

//NumTables = n;
  To_CondFil = NULL;        // To avoid doing it several times
  return FALSE;
  } // end of InitTableList
Example #2
0
int TDBOCCUR::GetMaxSize(PGLOBAL g)
  {
  if (MaxSize < 0) {
    if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
      return 0;
  
		MaxSize = Mult * Tdbp->GetMaxSize(g);
		} // endif MaxSize

  return MaxSize;
  } // end of GetMaxSize
Example #3
0
bool TDBPRX::InitTable(PGLOBAL g)
  {
  if (!Tdbp) {
    // Get the table description block of this table
    if (!(Tdbp = GetSubTable(g, ((PPRXDEF)To_Def)->Tablep)))
      return TRUE;

    } // endif Tdbp

  return FALSE;
  } // end of InitTable
Example #4
0
bool TDBPRX::InitTable(PGLOBAL g)
  {
  if (!Tdbp) {
    // Get the table description block of this table
    if (!(Tdbp = GetSubTable(g, ((PPRXDEF)To_Def)->Tablep)))
      return true;

//  Tdbp->SetMode(Mode);
    } // endif Tdbp

  return false;
  } // end of InitTable
Example #5
0
bool TDBOCCUR::InitTable(PGLOBAL g)
  {
  if (!Tdbp)
    // Get the table description block of this table
    if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
      return TRUE;

  if (!Tdbp->IsView())
  	if (MakeColumnList(g))
      return TRUE;

  return FALSE;
  } // end of InitTable
Example #6
0
bool TDBPIVOT::GetSourceTable(PGLOBAL g)
  {
  if (Tdbp)
    return false;             // Already done

  if (!Tabsrc && Tabname) {
    // Get the table description block of this table
    if (!(Tdbp = GetSubTable(g, ((PPIVOTDEF)To_Def)->Tablep, true)))
      return true;

    if (!GBdone) {
      char   *colist;
      PCOLDEF cdp;

      if (FindDefaultColumns(g))
        return true;
  
      // Locate the suballocated colist (size is not known yet)
      *(colist = (char*)PlugSubAlloc(g, NULL, 0)) = 0;
  
      // Make the column list
      for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext())
        if (!cdp->GetOffset())
          strcat(strcat(colist, cdp->GetName()), ", ");
  
      // Add the Pivot column at the end of the list
      strcat(colist, Picol);
  
      // Now we know how much was suballocated
      PlugSubAlloc(g, NULL, strlen(colist) + 1);
  
      // Locate the source string (size is not known yet)
      Tabsrc = (char*)PlugSubAlloc(g, NULL, 0);
  
      // Start making the definition
      strcat(strcat(strcpy(Tabsrc, "SELECT "), colist), ", ");
  
      // Make it suitable for Pivot by doing the group by
      strcat(strcat(Tabsrc, Function), "(");
      strcat(strcat(strcat(Tabsrc, Fncol), ") "), Fncol);
      strcat(strcat(Tabsrc, " FROM "), Tabname);
      strcat(strcat(Tabsrc, " GROUP BY "), colist);
  
      if (Tdbp->IsView())     // Until MariaDB bug is fixed
        strcat(strcat(Tabsrc, " ORDER BY "), colist);

      // Now we know how much was suballocated
      PlugSubAlloc(g, NULL, strlen(Tabsrc) + 1);
      } // endif !GBdone

  } else if (!Tabsrc) {
    strcpy(g->Message, MSG(SRC_TABLE_UNDEF));
    return true;
  } // endif

  if (Tabsrc) {
    // Get the new table description block of this source table
    PTABLE tablep = new(g) XTAB("whatever", Tabsrc);

    tablep->SetQualifier(Database);

    if (!(Tdbp = GetSubTable(g, tablep, true)))
      return true;

    } // endif Tabsrc

  return false;
  } // end of GetSourceTable