/ JDBCColumns: constructs the result blocks containing all columns */ of a JDBC table that will be retrieved by GetData commands. */ /
| 338 | /* of a JDBC table that will be retrieved by GetData commands. */ |
| 339 | /***********************************************************************/ |
| 340 | PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat, |
| 341 | int maxres, bool info, PJPARM sjp) |
| 342 | { |
| 343 | int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, |
| 344 | TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, |
| 345 | TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; |
| 346 | XFLD fldtyp[] = {FLD_CAT, FLD_SCHEM, FLD_TABNAME, FLD_NAME, |
| 347 | FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, |
| 348 | FLD_SCALE, FLD_RADIX, FLD_NULL, FLD_REM}; |
| 349 | unsigned int length[] = {0, 0, 0, 0, 6, 0, 10, 10, 6, 6, 6, 0}; |
| 350 | bool b[] = {true, true, false, false, false, false, false, false, true, true, false, true}; |
| 351 | int i, n, ncol = 12; |
| 352 | PCOLRES crp; |
| 353 | PQRYRES qrp; |
| 354 | JCATPARM *cap; |
| 355 | JDBConn *jcp = NULL; |
| 356 | |
| 357 | /************************************************************************/ |
| 358 | /* Do an evaluation of the result size. */ |
| 359 | /************************************************************************/ |
| 360 | if (!info) { |
| 361 | jcp = new(g)JDBConn(g, NULL); |
| 362 | |
| 363 | if (jcp->Connect(sjp)) // openReadOnly + noJDBCdialog |
| 364 | return NULL; |
| 365 | |
| 366 | if (table && !strchr(table, '%')) { |
| 367 | // We fix a MySQL limit because some data sources return 32767 |
| 368 | n = jcp->GetMaxValue(1); // MAX_COLUMNS_IN_TABLE) |
| 369 | maxres = (n > 0) ? MY_MIN(n, 4096) : 4096; |
| 370 | } else if (!maxres) |
| 371 | maxres = 20000; |
| 372 | |
| 373 | // n = jcp->GetMaxValue(2); MAX_CATALOG_NAME_LEN |
| 374 | // length[0] = (n) ? (n + 1) : 0; |
| 375 | // n = jcp->GetMaxValue(3); MAX_SCHEMA_NAME_LEN |
| 376 | // length[1] = (n) ? (n + 1) : 0; |
| 377 | // n = jcp->GetMaxValue(4); MAX_TABLE_NAME_LEN |
| 378 | // length[2] = (n) ? (n + 1) : 0; |
| 379 | n = jcp->GetMaxValue(5); // MAX_COLUMN_NAME_LEN |
| 380 | length[3] = (n > 0) ? (n + 1) : 128; |
| 381 | } else { // Info table |
| 382 | maxres = 0; |
| 383 | length[0] = 128; |
| 384 | length[1] = 128; |
| 385 | length[2] = 128; |
| 386 | length[3] = 128; |
| 387 | length[5] = 30; |
| 388 | length[11] = 255; |
| 389 | } // endif jcp |
| 390 | |
| 391 | if (trace(1)) |
| 392 | htrc("JDBCColumns: max=%d len=%d,%d,%d,%d\n", |
| 393 | maxres, length[0], length[1], length[2], length[3]); |
| 394 | |
| 395 | /************************************************************************/ |
| 396 | /* Allocate the structures used to refer to the result set. */ |
| 397 | /************************************************************************/ |
no test coverage detected