* \dA * Takes an optional regexp to select particular access methods */
| 300 | * Takes an optional regexp to select particular access methods |
| 301 | */ |
| 302 | bool |
| 303 | describeAccessMethods(const char *pattern, bool verbose) |
| 304 | { |
| 305 | PQExpBufferData buf; |
| 306 | PGresult *res; |
| 307 | printQueryOpt myopt = pset.popt; |
| 308 | static const bool translate_columns[] = {false, true, false, false}; |
| 309 | |
| 310 | if (pset.sversion < 90600) |
| 311 | { |
| 312 | char sverbuf[32]; |
| 313 | |
| 314 | pg_log_error("The server (version %s) does not support access methods.", |
| 315 | formatPGVersionNumber(pset.sversion, false, |
| 316 | sverbuf, sizeof(sverbuf))); |
| 317 | return true; |
| 318 | } |
| 319 | |
| 320 | initPQExpBuffer(&buf); |
| 321 | |
| 322 | printfPQExpBuffer(&buf, |
| 323 | "SELECT amname AS \"%s\",\n" |
| 324 | " CASE amtype" |
| 325 | " WHEN 'i' THEN '%s'" |
| 326 | " WHEN 't' THEN '%s'" |
| 327 | " END AS \"%s\"", |
| 328 | gettext_noop("Name"), |
| 329 | gettext_noop("Index"), |
| 330 | gettext_noop("Table"), |
| 331 | gettext_noop("Type")); |
| 332 | |
| 333 | if (verbose) |
| 334 | { |
| 335 | appendPQExpBuffer(&buf, |
| 336 | ",\n amhandler AS \"%s\",\n" |
| 337 | " pg_catalog.obj_description(oid, 'pg_am') AS \"%s\"", |
| 338 | gettext_noop("Handler"), |
| 339 | gettext_noop("Description")); |
| 340 | } |
| 341 | |
| 342 | appendPQExpBufferStr(&buf, |
| 343 | "\nFROM pg_catalog.pg_am\n"); |
| 344 | |
| 345 | if (!validateSQLNamePattern(&buf, pattern, false, false, |
| 346 | NULL, "amname", NULL, |
| 347 | NULL, |
| 348 | NULL, 1)) |
| 349 | return false; |
| 350 | |
| 351 | appendPQExpBufferStr(&buf, "ORDER BY 1;"); |
| 352 | |
| 353 | res = PSQLexec(buf.data); |
| 354 | termPQExpBuffer(&buf); |
| 355 | if (!res) |
| 356 | return false; |
| 357 | |
| 358 | myopt.nullPrint = NULL; |
| 359 | myopt.title = _("List of access methods"); |
no test coverage detected