42 char *output_path =
"reindex_hash.sql";
46 for (dbnum = 0; dbnum <
cluster->dbarr.ndbs; dbnum++)
59 "SELECT n.nspname, c.relname "
60 "FROM pg_catalog.pg_class c, "
61 " pg_catalog.pg_index i, "
62 " pg_catalog.pg_am a, "
63 " pg_catalog.pg_namespace n "
64 "WHERE i.indexrelid = c.oid AND "
65 " c.relam = a.oid AND "
66 " c.relnamespace = n.oid AND "
73 for (rowno = 0; rowno < ntups; rowno++)
78 if (script == NULL && (script =
fopen_priv(output_path,
"w")) == NULL)
79 pg_fatal(
"could not open file \"%s\": %m", output_path);
86 fputs(connectbuf.
data, script);
90 fprintf(script,
"REINDEX INDEX %s.%s;\n",
98 if (!check_mode && db_used)
102 "UPDATE pg_catalog.pg_index i "
103 "SET indisvalid = false "
104 "FROM pg_catalog.pg_class c, "
105 " pg_catalog.pg_am a, "
106 " pg_catalog.pg_namespace n "
107 "WHERE i.indexrelid = c.oid AND "
108 " c.relam = a.oid AND "
109 " c.relnamespace = n.oid AND "
110 " a.amname = 'hash'"));
124 "Your installation contains hash indexes. These indexes have different\n"
125 "internal formats between your old and new clusters, so they must be\n"
126 "reindexed with the REINDEX command. After upgrading, you will be given\n"
127 "REINDEX instructions.");
130 "Your installation contains hash indexes. These indexes have different\n"
131 "internal formats between your old and new clusters, so they must be\n"
132 "reindexed with the REINDEX command. The file\n"
134 "when executed by psql by the database superuser will recreate all invalid\n"
135 "indexes; until then, none of these indexes will be used.",
160 if (report->
file == NULL &&
162 pg_fatal(
"could not open file \"%s\": %m", report->
path);
166 fputs(connectbuf.
data, report->
file);
169 for (
int rowno = 0; rowno < ntups; rowno++)
170 fprintf(report->
file,
"ALTER EXTENSION %s UPDATE;\n",
183 const char *query =
"SELECT name "
184 "FROM pg_available_extensions "
185 "WHERE installed_version != default_version";
190 strcpy(report.
path,
"update_extensions.sql");
203 "Your installation contains extensions that should be updated\n"
204 "with the ALTER EXTENSION command. The file\n"
206 "when executed by psql by the database superuser will update\n"
bool jsonb_9_4_check_applicable(ClusterInfo *cluster)
void report_extension_updates(ClusterInfo *cluster)
static void process_extension_updates(DbInfo *dbinfo, PGresult *res, void *arg)
void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
#define AssertVariableIsOfType(varname, typename)
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
#define fprintf(file, fmt, msg)
static void PGresult * res
void PQfinish(PGconn *conn)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQntuples(const PGresult *res)
int PQfnumber(const PGresult *res, const char *field_name)
static void check_ok(void)
static struct LogicalRepInfo * dbinfo
UpgradeTask * upgrade_task_create(void)
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
void upgrade_task_run(const UpgradeTask *task, const ClusterInfo *cluster)
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2
void upgrade_task_free(UpgradeTask *task)
#define fopen_priv(path, mode)
void(* UpgradeTaskProcessCB)(DbInfo *dbinfo, PGresult *res, void *arg)
#define GET_MAJOR_VERSION(v)
void prep_status(const char *fmt,...) pg_attribute_printf(1
void report_status(eLogType type, const char *fmt,...) pg_attribute_printf(2
void upgrade_task_add_step(UpgradeTask *task, const char *query, UpgradeTaskProcessCB process_cb, bool free_result, void *arg)
#define JSONB_FORMAT_CHANGE_CAT_VER
void initPQExpBuffer(PQExpBuffer str)
void termPQExpBuffer(PQExpBuffer str)
const char * quote_identifier(const char *ident)
void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname)