/ Initialize TDB based column description block construction. */ name is used to call columns by name. */ num is used by TBL to construct columns by index number. */ Note: name=Null and num=0 for constructing all columns (select *) */ /
| 123 | /* Note: name=Null and num=0 for constructing all columns (select *) */ |
| 124 | /***********************************************************************/ |
| 125 | PCOL TDB::ColDB(PGLOBAL g, PSZ name, int num) |
| 126 | { |
| 127 | int i; |
| 128 | PCOLDEF cdp; |
| 129 | PCOL cp, colp = NULL, cprec = NULL; |
| 130 | |
| 131 | if (trace(1)) |
| 132 | htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n", |
| 133 | GetAmType(), SVP(name), Name, num); |
| 134 | |
| 135 | for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++) |
| 136 | if ((!name && !num) || |
| 137 | (name && !stricmp(cdp->GetName(), name)) || num == i) { |
| 138 | /*****************************************************************/ |
| 139 | /* Check for existence of desired column. */ |
| 140 | /* Also find where to insert the new block. */ |
| 141 | /*****************************************************************/ |
| 142 | for (cp = Columns; cp; cp = cp->GetNext()) |
| 143 | if ((num && cp->GetIndex() == i) || |
| 144 | (name && !stricmp(cp->GetName(), name))) |
| 145 | break; // Found |
| 146 | else if (cp->GetIndex() < i) |
| 147 | cprec = cp; |
| 148 | |
| 149 | if (trace(1)) |
| 150 | htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp); |
| 151 | |
| 152 | /*****************************************************************/ |
| 153 | /* Now take care of Column Description Block. */ |
| 154 | /*****************************************************************/ |
| 155 | if (cp) |
| 156 | colp = cp; |
| 157 | else if (!(cdp->Flags & U_SPECIAL)) |
| 158 | colp = MakeCol(g, cdp, cprec, i); |
| 159 | else if (Mode != MODE_INSERT) |
| 160 | colp = InsertSpcBlk(g, cdp); |
| 161 | |
| 162 | if (trace(1)) |
| 163 | htrc("colp=%p\n", colp); |
| 164 | |
| 165 | if (name || num) |
| 166 | break; |
| 167 | else if (colp && !colp->IsSpecial()) |
| 168 | cprec = colp; |
| 169 | |
| 170 | } // endif Name |
| 171 | |
| 172 | return (colp); |
| 173 | } // end of ColDB |
| 174 | |
| 175 | /***********************************************************************/ |
| 176 | /* InsertSpecialColumn: Put a special column ahead of the column list.*/ |
no test coverage detected