Merge branch 'logging-cleanup'
This commit is contained in:
commit
b3304b8a69
@ -115,9 +115,14 @@ SELECT * FROM tbl_with_dropped_toast;
|
||||
-- do repack
|
||||
--
|
||||
\! pg_repack --dbname=contrib_regression --table=tbl_badindex
|
||||
INFO: repacking table "tbl_badindex"
|
||||
WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON tbl_badindex USING btree (n)
|
||||
\! pg_repack --dbname=contrib_regression
|
||||
INFO: repacking table "tbl_cluster"
|
||||
INFO: repacking table "tbl_with_dropped_column"
|
||||
INFO: repacking table "tbl_with_dropped_toast"
|
||||
\! pg_repack --dbname=contrib_regression --table=tbl_cluster
|
||||
INFO: repacking table "tbl_cluster"
|
||||
--
|
||||
-- after
|
||||
--
|
||||
@ -308,8 +313,10 @@ WARNING: relation "tbl_nn" must have a primary key or not-null unique keys
|
||||
WARNING: relation "tbl_uk" must have a primary key or not-null unique keys
|
||||
-- => WARNING
|
||||
\! pg_repack --dbname=contrib_regression --table=tbl_nn_uk
|
||||
INFO: repacking table "tbl_nn_uk"
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --table=tbl_pk_uk
|
||||
INFO: repacking table "tbl_pk_uk"
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --table=tbl_nn_puk
|
||||
WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys
|
||||
@ -326,6 +333,7 @@ SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass::
|
||||
(1 row)
|
||||
|
||||
\! pg_repack --dbname=contrib_regression --table=issue3_1
|
||||
INFO: repacking table "issue3_1"
|
||||
CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL);
|
||||
CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops);
|
||||
SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid);
|
||||
@ -335,6 +343,7 @@ SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::
|
||||
(1 row)
|
||||
|
||||
\! pg_repack --dbname=contrib_regression --table=issue3_2
|
||||
INFO: repacking table "issue3_2"
|
||||
CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL);
|
||||
CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC);
|
||||
SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid);
|
||||
@ -344,6 +353,7 @@ SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::
|
||||
(1 row)
|
||||
|
||||
\! pg_repack --dbname=contrib_regression --table=issue3_3
|
||||
INFO: repacking table "issue3_3"
|
||||
CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL);
|
||||
CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
|
||||
SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid);
|
||||
@ -353,6 +363,7 @@ SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::
|
||||
(1 row)
|
||||
|
||||
\! pg_repack --dbname=contrib_regression --table=issue3_4
|
||||
INFO: repacking table "issue3_4"
|
||||
CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL);
|
||||
CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC);
|
||||
SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid);
|
||||
@ -362,3 +373,4 @@ SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::
|
||||
(1 row)
|
||||
|
||||
\! pg_repack --dbname=contrib_regression --table=issue3_5
|
||||
INFO: repacking table "issue3_5"
|
||||
|
@ -18,6 +18,7 @@ INSERT INTO testts1 (data) values ('b');
|
||||
INSERT INTO testts1 (data) values ('c');
|
||||
-- can move the tablespace from default
|
||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts
|
||||
INFO: repacking table "testts1"
|
||||
SELECT relname, spcname
|
||||
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||
WHERE relname ~ '^testts1'
|
||||
@ -37,6 +38,7 @@ SELECT * from testts1 order by id;
|
||||
|
||||
-- tablespace stays where it is
|
||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1
|
||||
INFO: repacking table "testts1"
|
||||
SELECT relname, spcname
|
||||
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||
WHERE relname ~ '^testts1'
|
||||
@ -48,6 +50,7 @@ ORDER BY relname;
|
||||
|
||||
-- can move the ts back to default
|
||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 -s pg_default
|
||||
INFO: repacking table "testts1"
|
||||
SELECT relname, spcname
|
||||
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||
WHERE relname ~ '^testts1'
|
||||
@ -58,6 +61,7 @@ ORDER BY relname;
|
||||
|
||||
-- can move the table together with the indexes
|
||||
\! pg_repack --dbname=contrib_regression --no-order --table=testts1 --tablespace testts --moveidx
|
||||
INFO: repacking table "testts1"
|
||||
SELECT relname, spcname
|
||||
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace
|
||||
WHERE relname ~ '^testts1'
|
||||
|
@ -186,6 +186,7 @@ static bool kill_ddl(PGconn *conn, Oid relid, bool terminate);
|
||||
static bool lock_access_share(PGconn *conn, Oid relid, const char *target_name);
|
||||
|
||||
#define SQLSTATE_INVALID_SCHEMA_NAME "3F000"
|
||||
#define SQLSTATE_UNDEFINED_FUNCTION "42883"
|
||||
#define SQLSTATE_QUERY_CANCELED "57014"
|
||||
|
||||
static bool sqlstate_equals(PGresult *res, const char *state)
|
||||
@ -364,22 +365,10 @@ repack_all_databases(const char *orderby)
|
||||
|
||||
dbname = PQgetvalue(result, i, 0);
|
||||
|
||||
if (pgut_log_level >= INFO)
|
||||
{
|
||||
printf("%s: repack database \"%s\"\n", PROGRAM_NAME, dbname);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
elog(INFO, "repacking database \"%s\"", dbname);
|
||||
ret = repack_one_database(orderby, errbuf, sizeof(errbuf));
|
||||
|
||||
if (pgut_log_level >= INFO)
|
||||
{
|
||||
if (ret)
|
||||
printf("\n");
|
||||
else
|
||||
printf(" ... skipped: %s\n", errbuf);
|
||||
fflush(stdout);
|
||||
}
|
||||
if (!ret)
|
||||
elog(INFO, "database \"%s\" skipped: %s", dbname, errbuf);
|
||||
}
|
||||
|
||||
CLEARPGRES(result);
|
||||
@ -477,12 +466,16 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sqlstate_equals(res, SQLSTATE_INVALID_SCHEMA_NAME))
|
||||
if (sqlstate_equals(res, SQLSTATE_INVALID_SCHEMA_NAME)
|
||||
|| sqlstate_equals(res, SQLSTATE_UNDEFINED_FUNCTION))
|
||||
{
|
||||
/* Schema repack does not exist. Skip the database. */
|
||||
/* Schema repack does not exist, or version too old (version
|
||||
* functions not found). Skip the database.
|
||||
*/
|
||||
if (errbuf)
|
||||
snprintf(errbuf, errsize,
|
||||
"%s is not installed in the database", PROGRAM_NAME);
|
||||
"%s %s is not installed in the database",
|
||||
PROGRAM_NAME, PROGRAM_VERSION);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -546,20 +539,10 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
|
||||
/* on error skip the database */
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
if (sqlstate_equals(res, SQLSTATE_INVALID_SCHEMA_NAME))
|
||||
{
|
||||
/* Schema repack does not exist. Skip the database. */
|
||||
if (errbuf)
|
||||
snprintf(errbuf, errsize,
|
||||
"%s is not installed in the database", PROGRAM_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return the error message otherwise */
|
||||
if (errbuf)
|
||||
snprintf(errbuf, errsize, "%s", PQerrorMessage(connection));
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -935,6 +918,8 @@ repack_one_table(const repack_table *table, const char *orderby)
|
||||
|
||||
initStringInfo(&sql);
|
||||
|
||||
elog(INFO, "repacking table \"%s\"", table->target_name);
|
||||
|
||||
elog(DEBUG2, "---- repack_one_table ----");
|
||||
elog(DEBUG2, "target_name : %s", table->target_name);
|
||||
elog(DEBUG2, "target_oid : %u", table->target_oid);
|
||||
@ -1029,12 +1014,6 @@ repack_one_table(const repack_table *table, const char *orderby)
|
||||
* pg_locks momentarily.
|
||||
*/
|
||||
res = pgut_execute(conn2, "SELECT pg_backend_pid()", 0, NULL);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
printf("%s", PQerrorMessage(conn2));
|
||||
have_error = true;
|
||||
goto cleanup;
|
||||
}
|
||||
buffer[0] = '\0';
|
||||
strncat(buffer, PQgetvalue(res, 0, 0), sizeof(buffer) - 1);
|
||||
CLEARPGRES(res);
|
||||
|
Loading…
x
Reference in New Issue
Block a user