MCPcopy Create free account
hub / github.com/apache/cloudberry / run_reindex_command

Function run_reindex_command

src/bin/scripts/reindexdb.c:513–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511}
512
513static void
514run_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.

Callers 1

reindex_one_databaseFunction · 0.85

Calls 13

initPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
appendPQExpBufferFunction · 0.85
fmtIdEncFunction · 0.85
PQclientEncodingFunction · 0.85
appendQualifiedRelationFunction · 0.85
appendPQExpBufferCharFunction · 0.85
PQsendQueryFunction · 0.85
PQdbFunction · 0.85
PQerrorMessageFunction · 0.85
PQfinishFunction · 0.85

Tested by

no test coverage detected