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

Function TabColumns

storage/connect/tabutil.cpp:124–303  ·  view source on GitHub ↗

/ TabColumns: constructs the result blocks containing all the columns */ description of the object table that will be retrieved by discovery.*/ /

Source from the content-addressed store, hash-verified

122/* description of the object table that will be retrieved by discovery.*/
123/************************************************************************/
124PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
125 const char *name, bool& info)
126 {
127 int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
128 TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
129 TYPE_STRING, TYPE_STRING, TYPE_STRING};
130 XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
131 FLD_LENGTH, FLD_SCALE, FLD_RADIX, FLD_NULL,
132 FLD_REM, FLD_NO, FLD_CHARSET};
133 unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32};
134 PCSZ fmt;
135 char *pn, *tn, *fld, *colname, v; // *chset
136 int i, n, ncol = sizeof(buftyp) / sizeof(int);
137 int prec, len, type, scale;
138 int zconv = GetConvSize();
139 bool mysql;
140 TABLE_SHARE *s = NULL;
141 Field* *field;
142 Field *fp;
143 PQRYRES qrp;
144 PCOLRES crp;
145
146 if (!info) {
147 // Analyze the table name, it may have the format: [dbname.]tabname
148 if (strchr((char*)name, '.')) {
149 tn = (char*)PlugDup(g, name);
150 pn = strchr(tn, '.');
151 *pn++ = 0;
152 db = tn;
153 name = pn;
154 } // endif pn
155
156 if (!(s = GetTableShare(g, thd, db, name, mysql))) {
157 return NULL;
158 } else if (s->is_view) {
159 strcpy(g->Message, "Use MYSQL type to see columns from a view");
160 info = true; // To tell caller name is a view
161 free_table_share(s);
162 return NULL;
163 } else
164 n = s->fieldnames.count;
165
166 } else {
167 n = 0;
168 length[0] = 128;
169 } // endif info
170
171 /**********************************************************************/
172 /* Allocate the structures used to refer to the result set. */
173 /**********************************************************************/
174 if (!(qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
175 buftyp, fldtyp, length, false, true)))
176 return NULL;
177
178 // Some columns must be renamed
179 for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next)
180 switch (++i) {
181 case 2: crp->Nulls = (char*)PlugSubAlloc(g, NULL, n); break;

Callers 2

GetResultMethod · 0.85

Calls 15

GetConvSizeFunction · 0.85
PlugDupFunction · 0.85
GetTableShareFunction · 0.85
free_table_shareFunction · 0.85
PlgAllocResultFunction · 0.85
PlugSubAllocFunction · 0.85
MYSQLtoPLGFunction · 0.85
push_warningFunction · 0.85
GetTypeNameFunction · 0.85
MyDateFmtFunction · 0.85
SetValueMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected