|
25 | 25 | #include "catalog/indexing.h"
|
26 | 26 | #include "catalog/namespace.h"
|
27 | 27 | #include "catalog/objectaccess.h"
|
| 28 | +#include "catalog/pg_inherits_fn.h" |
28 | 29 | #include "catalog/pg_rewrite.h"
|
29 | 30 | #include "catalog/storage.h"
|
30 | 31 | #include "commands/policy.h"
|
@@ -411,12 +412,12 @@ DefineQueryRewrite(char *rulename,
|
411 | 412 | *
|
412 | 413 | * If so, check that the relation is empty because the storage for the
|
413 | 414 | * relation is going to be deleted. Also insist that the rel not have
|
414 |
| - * any triggers, indexes, child tables, policies, or RLS enabled. |
415 |
| - * (Note: these tests are too strict, because they will reject |
416 |
| - * relations that once had such but don't anymore. But we don't |
417 |
| - * really care, because this whole business of converting relations to |
418 |
| - * views is just a kluge to allow dump/reload of views that |
419 |
| - * participate in circular dependencies.) |
| 415 | + * any triggers, indexes, child or parent tables, RLS policies, or RLS |
| 416 | + * enabled. (Note: some of these tests are too strict, because they |
| 417 | + * will reject relations that once had such but don't anymore. But we |
| 418 | + * don't really care, because this whole business of converting |
| 419 | + * relations to views is just a kluge to allow dump/reload of views |
| 420 | + * that participate in circular dependencies.) |
420 | 421 | */
|
421 | 422 | if (event_relation->rd_rel->relkind != RELKIND_VIEW &&
|
422 | 423 | event_relation->rd_rel->relkind != RELKIND_MATVIEW)
|
@@ -453,6 +454,12 @@ DefineQueryRewrite(char *rulename,
|
453 | 454 | errmsg("could not convert table \"%s\" to a view because it has child tables",
|
454 | 455 | RelationGetRelationName(event_relation))));
|
455 | 456 |
|
| 457 | + if (has_superclass(RelationGetRelid(event_relation))) |
| 458 | + ereport(ERROR, |
| 459 | + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
| 460 | + errmsg("could not convert table \"%s\" to a view because it has parent tables", |
| 461 | + RelationGetRelationName(event_relation)))); |
| 462 | + |
456 | 463 | if (event_relation->rd_rel->relrowsecurity)
|
457 | 464 | ereport(ERROR,
|
458 | 465 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
|
0 commit comments