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

Method ParseJpath

storage/connect/tabbson.cpp:1912–1999  ·  view source on GitHub ↗

/ Parse the eventual passed Jpath information. */ This information can be specified in the Fieldfmt column option */ when creating the table. It permits to indicate the position of */ the node corresponding to that column. */ /

Source from the content-addressed store, hash-verified

1910/* the node corresponding to that column. */
1911/***********************************************************************/
1912bool BSONCOL::ParseJpath(PGLOBAL g)
1913{
1914 char* p, * p1 = NULL, * p2 = NULL, * pbuf = NULL;
1915 int i;
1916 bool a;
1917
1918 if (Parsed)
1919 return false; // Already done
1920 else if (InitValue(g))
1921 return true;
1922 else if (!Jpath)
1923 Jpath = Name;
1924
1925 if (To_Tdb->GetOrig()) {
1926 // This is an updated column, get nodes from origin
1927 for (PBSCOL colp = (PBSCOL)Tbp->GetColumns(); colp;
1928 colp = (PBSCOL)colp->GetNext())
1929 if (!stricmp(Name, colp->GetName())) {
1930 Nod = colp->Nod;
1931 Nodes = colp->Nodes;
1932 Xpd = colp->Xpd;
1933 goto fin;
1934 } // endif Name
1935
1936 snprintf(g->Message, sizeof(g->Message), "Cannot parse updated column %s", Name);
1937 return true;
1938 } // endif To_Orig
1939
1940 pbuf = PlugDup(g, Jpath);
1941 if (*pbuf == '$') pbuf++;
1942 if (*pbuf == Sep) pbuf++;
1943 if (*pbuf == '[') p1 = pbuf++;
1944
1945 // Estimate the required number of nodes
1946 for (i = 0, p = pbuf; (p = NextChr(p, Sep)); i++, p++)
1947 Nod++; // One path node found
1948
1949 Nodes = (PJNODE)PlugSubAlloc(g, NULL, (++Nod) * sizeof(JNODE));
1950 memset(Nodes, 0, (Nod) * sizeof(JNODE));
1951
1952 // Analyze the Jpath for this column
1953 for (i = 0, p = pbuf; p && i < Nod; i++, p = (p2 ? p2 : NULL)) {
1954 a = (p1 != NULL);
1955 p1 = strchr(p, '[');
1956 p2 = strchr(p, Sep);
1957
1958 if (!p2)
1959 p2 = p1;
1960 else if (p1) {
1961 if (p1 < p2)
1962 p2 = p1;
1963 else if (p1 == p2 + 1)
1964 *p2++ = 0; // Old syntax .[ or :[
1965 else
1966 p1 = NULL;
1967
1968 } // endif p1
1969

Callers 1

MakeColMethod · 0.45

Calls 9

PlugDupFunction · 0.85
NextChrFunction · 0.85
PlugSubAllocFunction · 0.85
IsNumFunction · 0.85
safe_strcpyFunction · 0.85
AllocateValueFunction · 0.85
GetColumnsMethod · 0.45
GetNextMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected