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

Function XMLColumns

storage/connect/tabxml.cpp:118–447  ·  view source on GitHub ↗

/ XMLColumns: construct the result blocks containing the description */ of all the columns of a table contained inside an XML file. */ /

Source from the content-addressed store, hash-verified

116/* of all the columns of a table contained inside an XML file. */
117/***********************************************************************/
118PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
119{
120 static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
121 TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
122 static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
123 FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT};
124 static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0};
125 char colname[65], fmt[129], buf[512];
126 int i, j, lvl, n = 0;
127 int ncol = sizeof(buftyp) / sizeof(int);
128 bool ok = true;
129 PCSZ fn, op;
130 PXCL xcol, xcp, fxcp = NULL, pxcp = NULL;
131 PLVL *lvlp, vp;
132 PXNODE node = NULL;
133 PXMLDEF tdp;
134 PTDBXML txmp;
135 PQRYRES qrp;
136 PCOLRES crp;
137
138 if (info) {
139 length[0] = 128;
140 length[7] = 256;
141 goto skipit;
142 } // endif info
143
144 if (GetIntegerTableOption(g, topt, "Multiple", 0)) {
145 snprintf(g->Message, sizeof(g->Message), "Cannot find column definition for multiple table");
146 return NULL;
147 } // endif Multiple
148
149 /*********************************************************************/
150 /* Open the input file. */
151 /*********************************************************************/
152 if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {
153 if (topt->http) // REST table can have default filename
154 fn = GetStringTableOption(g, topt, "Subtype", NULL);
155
156 if (!fn) {
157 snprintf(g->Message, sizeof(g->Message), MSG(MISSING_FNAME));
158 return NULL;
159 } else
160 topt->subtype = NULL;
161
162 } // endif fn
163
164 lvl = GetIntegerTableOption(g, topt, "Level", GetDefaultDepth());
165 lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
166 lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl;
167
168 if (trace(1))
169 htrc("File %s lvl=%d\n", topt->filename, lvl);
170
171 tdp = new(g) XMLDEF;
172 tdp->Fn = fn;
173
174 if (!(tdp->Database = SetPath(g, db)))
175 return NULL;

Callers 2

RESTColumnsFunction · 0.85

Calls 15

GetIntegerTableOptionFunction · 0.85
GetStringTableOptionFunction · 0.85
GetDefaultDepthFunction · 0.85
SetPathFunction · 0.85
GetBooleanTableOptionFunction · 0.85
PlugSubAllocFunction · 0.85
strmakeFunction · 0.85
PushWarningFunction · 0.85
PlugDupFunction · 0.85
PlgAllocResultFunction · 0.85
GetTypeNameFunction · 0.85
htrcFunction · 0.70

Tested by

no test coverage detected