Merge pull request #117 from funbringer/support_table_inheritance
Support table inheritance
This commit is contained in:
		| @ -240,6 +240,7 @@ static bool sqlstate_equals(PGresult *res, const char *state) | ||||
| static bool				analyze = true; | ||||
| static bool				alldb = false; | ||||
| static bool				noorder = false; | ||||
| static SimpleStringList	parent_table_list = {NULL, NULL}; | ||||
| static SimpleStringList	table_list = {NULL, NULL}; | ||||
| static SimpleStringList	schema_list = {NULL, NULL}; | ||||
| static char				*orderby = NULL; | ||||
| @ -268,6 +269,7 @@ static pgut_option options[] = | ||||
| { | ||||
| 	{ 'b', 'a', "all", &alldb }, | ||||
| 	{ 'l', 't', "table", &table_list }, | ||||
| 	{ 'l', 'I', "parent-table", &parent_table_list }, | ||||
| 	{ 'l', 'c', "schema", &schema_list }, | ||||
| 	{ 'b', 'n', "no-order", &noorder }, | ||||
| 	{ 'b', 'N', "dry-run", &dryrun }, | ||||
| @ -310,15 +312,19 @@ main(int argc, char *argv[]) | ||||
| 		if (r_index.head && table_list.head) | ||||
| 			ereport(ERROR, (errcode(EINVAL), | ||||
| 				errmsg("cannot specify --index (-i) and --table (-t)"))); | ||||
| 		if (r_index.head && parent_table_list.head) | ||||
| 			ereport(ERROR, (errcode(EINVAL), | ||||
| 				errmsg("cannot specify --index (-i) and --parent-table (-I)"))); | ||||
| 		else if (r_index.head && only_indexes) | ||||
| 			ereport(ERROR, (errcode(EINVAL), | ||||
| 				errmsg("cannot specify --index (-i) and --only-indexes (-x)"))); | ||||
| 		else if (r_index.head && exclude_extension_list.head) | ||||
| 			ereport(ERROR, (errcode(EINVAL), | ||||
| 				errmsg("cannot specify --index (-i) and --exclude-extension (-C)"))); | ||||
| 		else if (only_indexes && !table_list.head) | ||||
| 		else if (only_indexes && !(table_list.head || parent_table_list.head)) | ||||
| 			ereport(ERROR, (errcode(EINVAL), | ||||
| 				errmsg("cannot repack all indexes of database, specify the table(s) via --table (-t)"))); | ||||
| 				errmsg("cannot repack all indexes of database, specify the table(s)" | ||||
| 					   "via --table (-t) or --parent-table (-I)"))); | ||||
| 		else if (only_indexes && exclude_extension_list.head) | ||||
| 			ereport(ERROR, (errcode(EINVAL), | ||||
| 				errmsg("cannot specify --only-indexes (-x) and --exclude-extension (-C)"))); | ||||
| @ -346,7 +352,7 @@ main(int argc, char *argv[]) | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		if (schema_list.head && table_list.head) | ||||
| 		if (schema_list.head && (table_list.head || parent_table_list.head)) | ||||
| 			ereport(ERROR, | ||||
| 				(errcode(EINVAL), | ||||
| 				 errmsg("cannot repack specific table(s) in schema, use schema.table notation instead"))); | ||||
| @ -356,12 +362,17 @@ main(int argc, char *argv[]) | ||||
| 				(errcode(EINVAL), | ||||
| 				 errmsg("cannot specify --table (-t) and --exclude-extension (-C)"))); | ||||
|  | ||||
| 		if (exclude_extension_list.head && parent_table_list.head) | ||||
| 			ereport(ERROR, | ||||
| 				(errcode(EINVAL), | ||||
| 				 errmsg("cannot specify --parent-table (-I) and --exclude-extension (-C)"))); | ||||
|  | ||||
| 		if (noorder) | ||||
| 			orderby = ""; | ||||
|  | ||||
| 		if (alldb) | ||||
| 		{ | ||||
| 			if (table_list.head) | ||||
| 			if (table_list.head || parent_table_list.head) | ||||
| 				ereport(ERROR, | ||||
| 					(errcode(EINVAL), | ||||
| 					 errmsg("cannot repack specific table(s) in all databases"))); | ||||
| @ -617,17 +628,22 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) | ||||
| 	SimpleStringListCell   *cell; | ||||
| 	const char			  **params = NULL; | ||||
| 	int						iparam = 0; | ||||
| 	size_t					num_tables; | ||||
| 	size_t					num_schemas; | ||||
| 	size_t					num_params; | ||||
| 	size_t					num_excluded_extensions; | ||||
| 	size_t					num_parent_tables, | ||||
| 							num_tables, | ||||
| 							num_schemas, | ||||
| 							num_params, | ||||
| 							num_excluded_extensions; | ||||
|  | ||||
| 	num_parent_tables = simple_string_list_size(parent_table_list); | ||||
| 	num_tables = simple_string_list_size(table_list); | ||||
| 	num_schemas = simple_string_list_size(schema_list); | ||||
| 	num_excluded_extensions = simple_string_list_size(exclude_extension_list); | ||||
|  | ||||
| 	/* 1st param is the user-specified tablespace */ | ||||
| 	num_params = num_excluded_extensions + num_tables + num_schemas + 1; | ||||
| 	num_params = num_excluded_extensions + | ||||
| 				 num_parent_tables + | ||||
| 				 num_tables + | ||||
| 				 num_schemas + 1; | ||||
| 	params = pgut_malloc(num_params * sizeof(char *)); | ||||
|  | ||||
| 	initStringInfo(&sql); | ||||
| @ -650,6 +666,9 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) | ||||
| 		" WHERE "); | ||||
|  | ||||
| 	params[iparam++] = tablespace; | ||||
| 	if (num_tables || num_parent_tables) | ||||
| 	{ | ||||
| 		/* standalone tables */ | ||||
| 		if (num_tables) | ||||
| 		{ | ||||
| 			appendStringInfoString(&sql, "("); | ||||
| @ -663,6 +682,27 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) | ||||
| 			} | ||||
| 			appendStringInfoString(&sql, ")"); | ||||
| 		} | ||||
|  | ||||
| 		if (num_tables && num_parent_tables) | ||||
| 			appendStringInfoString(&sql, " OR "); | ||||
|  | ||||
| 		/* parent tables + inherited children */ | ||||
| 		if (num_parent_tables) | ||||
| 		{ | ||||
| 			appendStringInfoString(&sql, "("); | ||||
| 			for (cell = parent_table_list.head; cell; cell = cell->next) | ||||
| 			{ | ||||
| 				/* Construct table name placeholders to be used by PQexecParams */ | ||||
| 				appendStringInfo(&sql, | ||||
| 								 "relid = ANY(repack.get_table_and_inheritors($%d::regclass))", | ||||
| 								 iparam + 1); | ||||
| 				params[iparam++] = cell->val; | ||||
| 				if (cell->next) | ||||
| 					appendStringInfoString(&sql, " OR "); | ||||
| 			} | ||||
| 			appendStringInfoString(&sql, ")"); | ||||
| 		} | ||||
| 	} | ||||
| 	else if (num_schemas) | ||||
| 	{ | ||||
| 		appendStringInfoString(&sql, "schemaname IN ("); | ||||
| @ -2058,7 +2098,7 @@ repack_all_indexes(char *errbuf, size_t errsize) | ||||
| 	initStringInfo(&sql); | ||||
| 	reconnect(ERROR); | ||||
|  | ||||
| 	assert(r_index.head || table_list.head); | ||||
| 	assert(r_index.head || table_list.head || parent_table_list.head); | ||||
|  | ||||
| 	if (!preliminary_checks(errbuf, errsize)) | ||||
| 		goto cleanup; | ||||
| @ -2073,7 +2113,7 @@ repack_all_indexes(char *errbuf, size_t errsize) | ||||
|  | ||||
| 		cell = r_index.head; | ||||
| 	} | ||||
| 	else if (table_list.head) | ||||
| 	else if (table_list.head || parent_table_list.head) | ||||
| 	{ | ||||
| 		appendStringInfoString(&sql, | ||||
| 			"SELECT i.relname, idx.indexrelid, idx.indisvalid, idx.indrelid, $1::text, n.nspname" | ||||
| @ -2081,6 +2121,39 @@ repack_all_indexes(char *errbuf, size_t errsize) | ||||
| 			" JOIN pg_namespace n ON n.oid = i.relnamespace" | ||||
| 			" WHERE idx.indrelid = $1::regclass ORDER BY indisvalid DESC, i.relname, n.nspname"); | ||||
|  | ||||
| 		for (cell = parent_table_list.head; cell; cell = cell->next) | ||||
| 		{ | ||||
| 			int nchildren, i; | ||||
|  | ||||
| 			params[0] = cell->val; | ||||
|  | ||||
| 			/* find children of this parent table */ | ||||
| 			res = execute_elevel("SELECT quote_ident(n.nspname) || '.' || quote_ident(c.relname)" | ||||
| 								 " FROM pg_class c JOIN pg_namespace n on n.oid = c.relnamespace" | ||||
| 								 " WHERE c.oid = ANY (repack.get_table_and_inheritors($1::regclass))" | ||||
| 								 " ORDER BY n.nspname, c.relname", 1, params, DEBUG2); | ||||
|  | ||||
| 			if (PQresultStatus(res) != PGRES_TUPLES_OK) | ||||
| 			{ | ||||
| 				elog(WARNING, "%s", PQerrorMessage(connection)); | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			nchildren = PQntuples(res); | ||||
|  | ||||
| 			if (nchildren == 0) | ||||
| 			{ | ||||
| 				elog(WARNING, "relation \"%s\" does not exist", cell->val); | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			/* append new tables to 'table_list' */ | ||||
| 			for (i = 0; i < nchildren; i++) | ||||
| 				simple_string_list_append(&table_list, getstr(res, i, 0)); | ||||
| 		} | ||||
|  | ||||
| 		CLEARPGRES(res); | ||||
|  | ||||
| 		cell = table_list.head; | ||||
| 	} | ||||
|  | ||||
| @ -2118,7 +2191,6 @@ repack_all_indexes(char *errbuf, size_t errsize) | ||||
| 	ret = true; | ||||
|  | ||||
| cleanup: | ||||
| 	CLEARPGRES(res); | ||||
| 	disconnect(); | ||||
| 	termStringInfo(&sql); | ||||
| 	return ret; | ||||
| @ -2137,6 +2209,7 @@ pgut_help(bool details) | ||||
| 	printf("Options:\n"); | ||||
| 	printf("  -a, --all                 repack all databases\n"); | ||||
| 	printf("  -t, --table=TABLE         repack specific table only\n"); | ||||
| 	printf("  -I, --parent-table=TABLE  repack specific parent table and its inheritors\n"); | ||||
| 	printf("  -c, --schema=SCHEMA       repack tables in specific schema only\n"); | ||||
| 	printf("  -s, --tablespace=TBLSPC   move repacked tables to a new tablespace\n"); | ||||
| 	printf("  -S, --moveidx             move repacked indexes to TBLSPC too\n"); | ||||
|  | ||||
| @ -108,6 +108,7 @@ The following options can be specified in ``OPTIONS``. | ||||
| Options: | ||||
|   -a, --all                 repack all databases | ||||
|   -t, --table=TABLE         repack specific table only | ||||
|   -I, --parent-table=TABLE  repack specific parent table and its inheritors | ||||
|   -c, --schema=SCHEMA       repack tables in specific schema only | ||||
|   -s, --tablespace=TBLSPC   move repacked tables to a new tablespace | ||||
|   -S, --moveidx             move repacked indexes to *TBLSPC* too | ||||
| @ -150,6 +151,10 @@ Reorg Options | ||||
|     reorganized by writing multiple ``-t`` switches. By default, all eligible | ||||
|     tables in the target databases are reorganized. | ||||
|  | ||||
| ``-I TABLE``, ``--parent-table=TABLE`` | ||||
|     Reorganize both the specified table(s) and its inheritors. Multiple | ||||
|     table hierarchies may be reorganized by writing multiple ``-I`` switches. | ||||
|  | ||||
| ``-c``, ``--schema`` | ||||
|     Repack the tables in the specified schema(s) only. Multiple schemas may | ||||
|     be repacked by writing multiple ``-c`` switches. May be used in | ||||
| @ -189,7 +194,7 @@ Reorg Options | ||||
|  | ||||
| ``-x``, ``--only-indexes`` | ||||
|     Repack only the indexes of the specified table(s), which must be specified | ||||
|     with the ``--table`` option. | ||||
|     with the ``--table`` or ``--parent-table`` options. | ||||
|  | ||||
| ``-T SECS``, ``--wait-timeout=SECS`` | ||||
|     pg_repack needs to take an exclusive lock at the end of the | ||||
| @ -222,7 +227,7 @@ Connection Options | ||||
| ^^^^^^^^^^^^^^^^^^ | ||||
|  | ||||
| Options to connect to servers. You cannot use ``--all`` and ``--dbname`` or | ||||
| ``--table`` together. | ||||
| ``--table`` or ``--parent-table`` together. | ||||
|  | ||||
| ``-a``, ``--all`` | ||||
|     Reorganize all databases. | ||||
|  | ||||
| @ -8,12 +8,14 @@ pg_finfo_repack_swap               7 | ||||
| pg_finfo_repack_trigger                    8 | ||||
| pg_finfo_repack_version                    9 | ||||
| pg_finfo_repack_index_swap                10 | ||||
| repack_apply                      11 | ||||
| repack_disable_autovacuum         12 | ||||
| repack_drop                       13 | ||||
| repack_get_order_by               14 | ||||
| repack_indexdef                   15 | ||||
| repack_swap                       16 | ||||
| repack_trigger                    17 | ||||
| repack_version                    18 | ||||
| repack_index_swap                 19 | ||||
| pg_finfo_repack_get_table_and_inheritors  11 | ||||
| repack_apply                              12 | ||||
| repack_disable_autovacuum                 13 | ||||
| repack_drop                               14 | ||||
| repack_get_order_by                       15 | ||||
| repack_indexdef                           16 | ||||
| repack_swap                               17 | ||||
| repack_trigger                            18 | ||||
| repack_version                            19 | ||||
| repack_index_swap                         20 | ||||
| repack_get_table_and_inheritors           21 | ||||
|  | ||||
| @ -322,3 +322,7 @@ LANGUAGE C VOLATILE STRICT; | ||||
| CREATE FUNCTION repack.repack_index_swap(oid) RETURNS void AS | ||||
| 'MODULE_PATHNAME', 'repack_index_swap' | ||||
| LANGUAGE C STABLE STRICT; | ||||
|  | ||||
| CREATE FUNCTION repack.get_table_and_inheritors(regclass) RETURNS regclass[] AS | ||||
| 'MODULE_PATHNAME', 'repack_get_table_and_inheritors' | ||||
| LANGUAGE C STABLE STRICT; | ||||
|  | ||||
							
								
								
									
										55
									
								
								lib/repack.c
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								lib/repack.c
									
									
									
									
									
								
							| @ -25,12 +25,15 @@ | ||||
| #include "catalog/pg_am.h" | ||||
| #endif | ||||
|  | ||||
| #include "catalog/pg_inherits_fn.h" | ||||
| #include "catalog/pg_namespace.h" | ||||
| #include "catalog/pg_opclass.h" | ||||
| #include "catalog/pg_type.h" | ||||
| #include "commands/tablecmds.h" | ||||
| #include "commands/trigger.h" | ||||
| #include "miscadmin.h" | ||||
| #include "storage/lmgr.h" | ||||
| #include "utils/array.h" | ||||
| #include "utils/builtins.h" | ||||
| #include "utils/lsyscache.h" | ||||
| #include "utils/rel.h" | ||||
| @ -61,6 +64,7 @@ extern Datum PGUT_EXPORT repack_swap(PG_FUNCTION_ARGS); | ||||
| extern Datum PGUT_EXPORT repack_drop(PG_FUNCTION_ARGS); | ||||
| extern Datum PGUT_EXPORT repack_disable_autovacuum(PG_FUNCTION_ARGS); | ||||
| extern Datum PGUT_EXPORT repack_index_swap(PG_FUNCTION_ARGS); | ||||
| extern Datum PGUT_EXPORT repack_get_table_and_inheritors(PG_FUNCTION_ARGS); | ||||
|  | ||||
| PG_FUNCTION_INFO_V1(repack_version); | ||||
| PG_FUNCTION_INFO_V1(repack_trigger); | ||||
| @ -71,6 +75,7 @@ PG_FUNCTION_INFO_V1(repack_swap); | ||||
| PG_FUNCTION_INFO_V1(repack_drop); | ||||
| PG_FUNCTION_INFO_V1(repack_disable_autovacuum); | ||||
| PG_FUNCTION_INFO_V1(repack_index_swap); | ||||
| PG_FUNCTION_INFO_V1(repack_get_table_and_inheritors); | ||||
|  | ||||
| static void	repack_init(void); | ||||
| static SPIPlanPtr repack_prepare(const char *src, int nargs, Oid *argtypes); | ||||
| @ -1289,3 +1294,53 @@ repack_index_swap(PG_FUNCTION_ARGS) | ||||
| 	SPI_finish(); | ||||
| 	PG_RETURN_VOID(); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @fn      Datum get_table_and_inheritors(PG_FUNCTION_ARGS) | ||||
|  * @brief   Return array containing Oids of parent table and its children. | ||||
|  *          Note that this function does not release relation locks. | ||||
|  * | ||||
|  * get_table_and_inheritors(table) | ||||
|  * | ||||
|  * @param	table	parent table. | ||||
|  * @retval	regclass[] | ||||
|  */ | ||||
| Datum | ||||
| repack_get_table_and_inheritors(PG_FUNCTION_ARGS) | ||||
| { | ||||
| 	Oid			parent = PG_GETARG_OID(0); | ||||
| 	List	   *relations; | ||||
| 	Datum	   *relations_array; | ||||
| 	int			relations_array_size; | ||||
| 	ArrayType  *result; | ||||
| 	ListCell   *lc; | ||||
| 	int			i; | ||||
|  | ||||
| 	LockRelationOid(parent, AccessShareLock); | ||||
|  | ||||
| 	/* Check that parent table exists */ | ||||
| 	if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(parent))) | ||||
| 		PG_RETURN_ARRAYTYPE_P(construct_empty_array(OIDOID)); | ||||
|  | ||||
| 	/* Also check that children exist */ | ||||
| 	relations = find_all_inheritors(parent, AccessShareLock, NULL); | ||||
|  | ||||
| 	relations_array_size = list_length(relations); | ||||
| 	if (relations_array_size == 0) | ||||
| 		PG_RETURN_ARRAYTYPE_P(construct_empty_array(OIDOID)); | ||||
|  | ||||
| 	relations_array = palloc(relations_array_size * sizeof(Datum)); | ||||
|  | ||||
| 	i = 0; | ||||
| 	foreach (lc, relations) | ||||
| 		relations_array[i++] = ObjectIdGetDatum(lfirst_oid(lc)); | ||||
|  | ||||
| 	result = construct_array(relations_array, | ||||
| 							 relations_array_size, | ||||
| 							 OIDOID, sizeof(Oid), | ||||
| 							 true, 'i'); | ||||
|  | ||||
| 	pfree(relations_array); | ||||
|  | ||||
| 	PG_RETURN_ARRAYTYPE_P(result); | ||||
| } | ||||
|  | ||||
| @ -474,3 +474,62 @@ INFO: repacking table "exclude_extension_schema.tbl" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension --exclude-extension=dummy_extension | ||||
| INFO: repacking table "exclude_extension_schema.tbl" | ||||
| -- | ||||
| -- table inheritance check | ||||
| -- | ||||
| CREATE TABLE parent_a(val integer primary key); | ||||
| CREATE TABLE child_a_1(val integer primary key) INHERITS(parent_a); | ||||
| CREATE TABLE child_a_2(val integer primary key) INHERITS(parent_a); | ||||
| CREATE TABLE parent_b(val integer primary key); | ||||
| CREATE TABLE child_b_1(val integer primary key) INHERITS(parent_b); | ||||
| CREATE TABLE child_b_2(val integer primary key) INHERITS(parent_b); | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table | ||||
| ERROR: pg_repack failed with error: ERROR:  relation "dummy_table" does not exist | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_index --index=dummy_index | ||||
| ERROR: cannot specify --index (-i) and --parent-table (-I) | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table --schema=dummy_schema | ||||
| ERROR: cannot repack specific table(s) in schema, use schema.table notation instead | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table --all | ||||
| ERROR: cannot repack specific table(s) in all databases | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b | ||||
| INFO: repacking table "parent_a" | ||||
| INFO: repacking table "parent_b" | ||||
| INFO: repacking table "child_b_1" | ||||
| INFO: repacking table "child_b_2" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b | ||||
| INFO: repacking table "parent_a" | ||||
| INFO: repacking table "child_a_1" | ||||
| INFO: repacking table "child_a_2" | ||||
| INFO: repacking table "parent_b" | ||||
| INFO: repacking table "child_b_1" | ||||
| INFO: repacking table "child_b_2" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b --only-indexes | ||||
| INFO: repacking indexes of "parent_a" | ||||
| INFO: repacking index "public"."parent_a_pkey" | ||||
| INFO: repacking indexes of "public.child_b_1" | ||||
| INFO: repacking index "public"."child_b_1_pkey" | ||||
| INFO: repacking indexes of "public.child_b_2" | ||||
| INFO: repacking index "public"."child_b_2_pkey" | ||||
| INFO: repacking indexes of "public.parent_b" | ||||
| INFO: repacking index "public"."parent_b_pkey" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b --only-indexes | ||||
| INFO: repacking indexes of "public.child_a_1" | ||||
| INFO: repacking index "public"."child_a_1_pkey" | ||||
| INFO: repacking indexes of "public.child_a_2" | ||||
| INFO: repacking index "public"."child_a_2_pkey" | ||||
| INFO: repacking indexes of "public.parent_a" | ||||
| INFO: repacking index "public"."parent_a_pkey" | ||||
| INFO: repacking indexes of "public.child_b_1" | ||||
| INFO: repacking index "public"."child_b_1_pkey" | ||||
| INFO: repacking indexes of "public.child_b_2" | ||||
| INFO: repacking index "public"."child_b_2_pkey" | ||||
| INFO: repacking indexes of "public.parent_b" | ||||
| INFO: repacking index "public"."parent_b_pkey" | ||||
|  | ||||
| @ -472,3 +472,62 @@ INFO: repacking table "exclude_extension_schema.tbl" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension --exclude-extension=dummy_extension | ||||
| INFO: repacking table "exclude_extension_schema.tbl" | ||||
| -- | ||||
| -- table inheritance check | ||||
| -- | ||||
| CREATE TABLE parent_a(val integer primary key); | ||||
| CREATE TABLE child_a_1(val integer primary key) INHERITS(parent_a); | ||||
| CREATE TABLE child_a_2(val integer primary key) INHERITS(parent_a); | ||||
| CREATE TABLE parent_b(val integer primary key); | ||||
| CREATE TABLE child_b_1(val integer primary key) INHERITS(parent_b); | ||||
| CREATE TABLE child_b_2(val integer primary key) INHERITS(parent_b); | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table | ||||
| ERROR: pg_repack failed with error: ERROR:  relation "dummy_table" does not exist | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_index --index=dummy_index | ||||
| ERROR: cannot specify --index (-i) and --parent-table (-I) | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table --schema=dummy_schema | ||||
| ERROR: cannot repack specific table(s) in schema, use schema.table notation instead | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table --all | ||||
| ERROR: cannot repack specific table(s) in all databases | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b | ||||
| INFO: repacking table "parent_a" | ||||
| INFO: repacking table "parent_b" | ||||
| INFO: repacking table "child_b_1" | ||||
| INFO: repacking table "child_b_2" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b | ||||
| INFO: repacking table "parent_a" | ||||
| INFO: repacking table "child_a_1" | ||||
| INFO: repacking table "child_a_2" | ||||
| INFO: repacking table "parent_b" | ||||
| INFO: repacking table "child_b_1" | ||||
| INFO: repacking table "child_b_2" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b --only-indexes | ||||
| INFO: repacking indexes of "parent_a" | ||||
| INFO: repacking index "public"."parent_a_pkey" | ||||
| INFO: repacking indexes of "public.child_b_1" | ||||
| INFO: repacking index "public"."child_b_1_pkey" | ||||
| INFO: repacking indexes of "public.child_b_2" | ||||
| INFO: repacking index "public"."child_b_2_pkey" | ||||
| INFO: repacking indexes of "public.parent_b" | ||||
| INFO: repacking index "public"."parent_b_pkey" | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b --only-indexes | ||||
| INFO: repacking indexes of "public.child_a_1" | ||||
| INFO: repacking index "public"."child_a_1_pkey" | ||||
| INFO: repacking indexes of "public.child_a_2" | ||||
| INFO: repacking index "public"."child_a_2_pkey" | ||||
| INFO: repacking indexes of "public.parent_a" | ||||
| INFO: repacking index "public"."parent_a_pkey" | ||||
| INFO: repacking indexes of "public.child_b_1" | ||||
| INFO: repacking index "public"."child_b_1_pkey" | ||||
| INFO: repacking indexes of "public.child_b_2" | ||||
| INFO: repacking index "public"."child_b_2_pkey" | ||||
| INFO: repacking indexes of "public.parent_b" | ||||
| INFO: repacking index "public"."parent_b_pkey" | ||||
|  | ||||
| @ -296,3 +296,29 @@ CREATE TABLE exclude_extension_schema.tbl(val integer primary key); | ||||
| \! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension --exclude-extension=dummy_extension | ||||
|  | ||||
| -- | ||||
| -- table inheritance check | ||||
| -- | ||||
| CREATE TABLE parent_a(val integer primary key); | ||||
| CREATE TABLE child_a_1(val integer primary key) INHERITS(parent_a); | ||||
| CREATE TABLE child_a_2(val integer primary key) INHERITS(parent_a); | ||||
| CREATE TABLE parent_b(val integer primary key); | ||||
| CREATE TABLE child_b_1(val integer primary key) INHERITS(parent_b); | ||||
| CREATE TABLE child_b_2(val integer primary key) INHERITS(parent_b); | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_index --index=dummy_index | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table --schema=dummy_schema | ||||
| -- => ERROR | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=dummy_table --all | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b --only-indexes | ||||
| -- => OK | ||||
| \! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b --only-indexes | ||||
|  | ||||
		Reference in New Issue
	
	Block a user