| 511 | } |
| 512 | |
| 513 | static void |
| 514 | run_reindex_command(PGconn *conn, ReindexType type, const char *name, |
| 515 | bool echo, bool verbose, bool concurrently, bool async, |
| 516 | const char *tablespace) |
| 517 | { |
| 518 | const char *paren = "("; |
| 519 | const char *comma = ", "; |
| 520 | const char *sep = paren; |
| 521 | PQExpBufferData sql; |
| 522 | bool status; |
| 523 | |
| 524 | Assert(name); |
| 525 | |
| 526 | /* build the REINDEX query */ |
| 527 | initPQExpBuffer(&sql); |
| 528 | |
| 529 | appendPQExpBufferStr(&sql, "REINDEX "); |
| 530 | |
| 531 | if (verbose) |
| 532 | { |
| 533 | appendPQExpBuffer(&sql, "%sVERBOSE", sep); |
| 534 | sep = comma; |
| 535 | } |
| 536 | |
| 537 | if (tablespace) |
| 538 | { |
| 539 | appendPQExpBuffer(&sql, "%sTABLESPACE %s", sep, |
| 540 | fmtIdEnc(tablespace, PQclientEncoding(conn))); |
| 541 | sep = comma; |
| 542 | } |
| 543 | |
| 544 | if (sep != paren) |
| 545 | appendPQExpBufferStr(&sql, ") "); |
| 546 | |
| 547 | /* object type */ |
| 548 | switch (type) |
| 549 | { |
| 550 | case REINDEX_DATABASE: |
| 551 | appendPQExpBufferStr(&sql, "DATABASE "); |
| 552 | break; |
| 553 | case REINDEX_INDEX: |
| 554 | appendPQExpBufferStr(&sql, "INDEX "); |
| 555 | break; |
| 556 | case REINDEX_SCHEMA: |
| 557 | appendPQExpBufferStr(&sql, "SCHEMA "); |
| 558 | break; |
| 559 | case REINDEX_SYSTEM: |
| 560 | appendPQExpBufferStr(&sql, "SYSTEM "); |
| 561 | break; |
| 562 | case REINDEX_TABLE: |
| 563 | appendPQExpBufferStr(&sql, "TABLE "); |
| 564 | break; |
| 565 | } |
| 566 | |
| 567 | /* |
| 568 | * Parenthesized grammar is only supported for CONCURRENTLY since |
| 569 | * PostgreSQL 14. Since 12, CONCURRENTLY can be specified after the |
| 570 | * object type. |
no test coverage detected