/ Make a dynamic index. */ /
| 1825 | /* Make a dynamic index. */ |
| 1826 | /***********************************************************************/ |
| 1827 | bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) |
| 1828 | { |
| 1829 | int k; |
| 1830 | volatile bool dynamic; |
| 1831 | bool brc; |
| 1832 | PCOL colp; |
| 1833 | PCOLDEF cdp; |
| 1834 | PVAL valp; |
| 1835 | PXLOAD pxp; |
| 1836 | volatile PKXBASE kxp; |
| 1837 | PKPDEF kdp; |
| 1838 | |
| 1839 | if (!xdp && !(xdp = To_Xdp)) { |
| 1840 | safe_strcpy(g->Message, sizeof(g->Message), "NULL dynamic index"); |
| 1841 | return true; |
| 1842 | } else |
| 1843 | dynamic = To_Filter && xdp->IsUnique() && xdp->IsDynamic(); |
| 1844 | // dynamic = To_Filter && xdp->IsDynamic(); NIY |
| 1845 | |
| 1846 | // Allocate the key columns definition block |
| 1847 | Knum = xdp->GetNparts(); |
| 1848 | To_Key_Col = (PCOL*)PlugSubAlloc(g, NULL, Knum * sizeof(PCOL)); |
| 1849 | |
| 1850 | // Get the key column description list |
| 1851 | for (k = 0, kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext()) |
| 1852 | if (!(colp = ColDB(g, kdp->GetName(), 0)) || colp->InitValue(g)) { |
| 1853 | snprintf(g->Message, sizeof(g->Message), "Wrong column %s", kdp->GetName()); |
| 1854 | return true; |
| 1855 | } else |
| 1856 | To_Key_Col[k++] = colp; |
| 1857 | |
| 1858 | #if defined(_DEBUG) |
| 1859 | if (k != Knum) { |
| 1860 | snprintf(g->Message, sizeof(g->Message), "Key part number mismatch for %s", |
| 1861 | xdp->GetName()); |
| 1862 | return 0; |
| 1863 | } // endif k |
| 1864 | #endif // _DEBUG |
| 1865 | |
| 1866 | // Allocate the pseudo constants that will contain the key values |
| 1867 | To_Link = (PXOB*)PlugSubAlloc(g, NULL, Knum * sizeof(PXOB)); |
| 1868 | |
| 1869 | for (k = 0, kdp = xdp->GetToKeyParts(); kdp; k++, kdp = kdp->GetNext()) { |
| 1870 | if ((cdp = Key(k)->GetCdp())) |
| 1871 | valp = AllocateValue(g, cdp->GetType(), cdp->GetLength()); |
| 1872 | else { // Special column ? |
| 1873 | colp = Key(k); |
| 1874 | valp = AllocateValue(g, colp->GetResultType(), colp->GetLength()); |
| 1875 | } // endif cdp |
| 1876 | |
| 1877 | To_Link[k]= new(g) CONSTANT(valp); |
| 1878 | } // endfor k |
| 1879 | |
| 1880 | // Make the index on xdp |
| 1881 | if (!xdp->IsAuto()) { |
| 1882 | if (!dynamic) { |
| 1883 | if (((PDOSDEF)To_Def)->Huge) |
| 1884 | pxp = new(g) XHUGE; |
no test coverage detected