Merge remote-tracking branch 'origin/master' into pg10
This commit is contained in:
@ -772,6 +772,7 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
repack_table table;
|
||||
StringInfoData copy_sql;
|
||||
const char *create_table_1;
|
||||
const char *create_table_2;
|
||||
const char *tablespace;
|
||||
@ -814,17 +815,27 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
table.sql_pop = getstr(res, i, c++);
|
||||
tablespace = getstr(res, i, c++);
|
||||
|
||||
/* Craft CREATE TABLE SQL */
|
||||
resetStringInfo(&sql);
|
||||
appendStringInfoString(&sql, create_table_1);
|
||||
appendStringInfoString(&sql, tablespace);
|
||||
appendStringInfoString(&sql, create_table_2);
|
||||
|
||||
/* Always append WITH NO DATA to CREATE TABLE SQL*/
|
||||
appendStringInfoString(&sql, " WITH NO DATA");
|
||||
table.create_table = sql.data;
|
||||
|
||||
/* Craft Copy SQL */
|
||||
initStringInfo(©_sql);
|
||||
appendStringInfoString(©_sql, table.copy_data);
|
||||
if (!orderby)
|
||||
|
||||
{
|
||||
if (ckey != NULL)
|
||||
{
|
||||
/* CLUSTER mode */
|
||||
appendStringInfoString(&sql, " ORDER BY ");
|
||||
appendStringInfoString(&sql, ckey);
|
||||
appendStringInfoString(©_sql, " ORDER BY ");
|
||||
appendStringInfoString(©_sql, ckey);
|
||||
}
|
||||
|
||||
/* else, VACUUM FULL mode (non-clustered tables) */
|
||||
@ -836,13 +847,10 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
else
|
||||
{
|
||||
/* User specified ORDER BY */
|
||||
appendStringInfoString(&sql, " ORDER BY ");
|
||||
appendStringInfoString(&sql, orderby);
|
||||
appendStringInfoString(©_sql, " ORDER BY ");
|
||||
appendStringInfoString(©_sql, orderby);
|
||||
}
|
||||
|
||||
/* Always append WITH NOT DATA */
|
||||
appendStringInfoString(&sql, " WITH NO DATA");
|
||||
table.create_table = sql.data;
|
||||
table.copy_data = copy_sql.data;
|
||||
|
||||
repack_one_table(&table, orderby);
|
||||
}
|
||||
@ -852,6 +860,7 @@ cleanup:
|
||||
CLEARPGRES(res);
|
||||
disconnect();
|
||||
termStringInfo(&sql);
|
||||
free(params);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1771,6 +1780,12 @@ lock_exclusive(PGconn *conn, const char *relid, const char *lock_query, bool sta
|
||||
{
|
||||
elog(WARNING, "timed out, do not cancel conflicting backends");
|
||||
ret = false;
|
||||
|
||||
/* Before exit the loop reset the transaction */
|
||||
if (start_xact)
|
||||
pgut_rollback(conn);
|
||||
else
|
||||
pgut_command(conn, "ROLLBACK TO SAVEPOINT repack_sp1", 0, NULL);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user