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

Method InitialyzeIndex

storage/connect/tabdos.cpp:1827–1934  ·  view source on GitHub ↗

/ Make a dynamic index. */ /

Source from the content-addressed store, hash-verified

1825/* Make a dynamic index. */
1826/***********************************************************************/
1827bool 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;

Callers 2

CntIndexInitFunction · 0.80
CntIndexReadFunction · 0.80

Calls 15

safe_strcpyFunction · 0.85
PlugSubAllocFunction · 0.85
AllocateValueFunction · 0.85
IsUsingTempFunction · 0.85
IsUniqueMethod · 0.80
InitValueMethod · 0.80
MakeMethod · 0.80
KeyFunction · 0.70
htrcFunction · 0.70
GetNextMethod · 0.45
GetNameMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected