/ MyColumns: constructs the result blocks containing all columns */ of a MySQL table or view. */ info = TRUE to get catalog column information. */ /
| 123 | /* info = TRUE to get catalog column information. */ |
| 124 | /************************************************************************/ |
| 125 | PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, |
| 126 | const char *user, const char *pwd, |
| 127 | const char *table, const char *colpat, |
| 128 | int port, bool info) |
| 129 | { |
| 130 | int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, |
| 131 | TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, |
| 132 | TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, |
| 133 | TYPE_STRING}; |
| 134 | XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, |
| 135 | FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL, |
| 136 | FLD_REM, FLD_NO, FLD_DEFAULT, FLD_EXTRA, |
| 137 | FLD_CHARSET}; |
| 138 | //unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0}; |
| 139 | unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0}; |
| 140 | PCSZ fmt; |
| 141 | char *fld, *colname, *chset, v, buf[128], uns[16], zero[16]; |
| 142 | int i, n, nf = 0, ncol = sizeof(buftyp) / sizeof(int); |
| 143 | int len, type, prec, rc; |
| 144 | bool b; |
| 145 | PQRYRES qrp; |
| 146 | PCOLRES crp; |
| 147 | MYSQLC myc; |
| 148 | |
| 149 | if (!port) |
| 150 | port = mysqld_port; |
| 151 | |
| 152 | if (!info) { |
| 153 | /********************************************************************/ |
| 154 | /* Open the connection with the MySQL server. */ |
| 155 | /********************************************************************/ |
| 156 | if (myc.Open(g, host, db, user, pwd, port)) |
| 157 | return NULL; |
| 158 | |
| 159 | /********************************************************************/ |
| 160 | /* Do an evaluation of the result size. */ |
| 161 | /********************************************************************/ |
| 162 | STRING cmd(g, 64, "SHOW FULL COLUMNS FROM "); |
| 163 | b = cmd.Append('`'); |
| 164 | b |= cmd.Append((PSZ)table); |
| 165 | b |= cmd.Append('`'); |
| 166 | |
| 167 | b |= cmd.Append(" FROM "); |
| 168 | b |= cmd.Append((PSZ)(db ? db : PlgGetUser(g)->DBName)); |
| 169 | |
| 170 | if (colpat) { |
| 171 | b |= cmd.Append(" LIKE "); |
| 172 | b |= cmd.Append((PSZ)colpat); |
| 173 | } // endif colpat |
| 174 | |
| 175 | if (b) { |
| 176 | strcpy(g->Message, "Out of memory"); |
| 177 | return NULL; |
| 178 | } // endif b |
| 179 | |
| 180 | if (trace(1)) |
| 181 | htrc("MyColumns: cmd='%s'\n", cmd.GetStr()); |
| 182 |
no test coverage detected