* dumpTableSchema * write the declaration (not data) of one user-defined table or view */
| 17719 | * write the declaration (not data) of one user-defined table or view |
| 17720 | */ |
| 17721 | static void |
| 17722 | dumpTableSchema(Archive *fout, const TableInfo *tbinfo) |
| 17723 | { |
| 17724 | DumpOptions *dopt = fout->dopt; |
| 17725 | PQExpBuffer q = createPQExpBuffer(); |
| 17726 | PQExpBuffer delq = createPQExpBuffer(); |
| 17727 | char *qrelname; |
| 17728 | char *qualrelname; |
| 17729 | int numParents; |
| 17730 | TableInfo **parents; |
| 17731 | int actual_atts; /* number of attrs in this CREATE statement */ |
| 17732 | const char *reltypename; |
| 17733 | char *storage; |
| 17734 | int j, |
| 17735 | k; |
| 17736 | bool hasExternalPartitions = false; |
| 17737 | char *ftoptions = NULL; |
| 17738 | char *srvname = NULL; |
| 17739 | char *foreign = ""; |
| 17740 | |
| 17741 | |
| 17742 | /* We had better have loaded per-column details about this table */ |
| 17743 | Assert(tbinfo->interesting); |
| 17744 | |
| 17745 | qrelname = pg_strdup(fmtId(tbinfo->dobj.name)); |
| 17746 | qualrelname = pg_strdup(fmtQualifiedDumpable(tbinfo)); |
| 17747 | |
| 17748 | if (tbinfo->hasoids) |
| 17749 | pg_log_warning("WITH OIDS is not supported anymore (table \"%s\")", |
| 17750 | qrelname); |
| 17751 | |
| 17752 | if (dopt->binary_upgrade) |
| 17753 | binary_upgrade_set_type_oids_by_rel_oid(fout, q, |
| 17754 | tbinfo->dobj.catId.oid); |
| 17755 | |
| 17756 | /* Is it a table or a view? */ |
| 17757 | if (tbinfo->relkind == RELKIND_VIEW) |
| 17758 | { |
| 17759 | PQExpBuffer result; |
| 17760 | |
| 17761 | /* |
| 17762 | * Note: keep this code in sync with the is_view case in dumpRule() |
| 17763 | */ |
| 17764 | |
| 17765 | reltypename = "VIEW"; |
| 17766 | |
| 17767 | appendPQExpBuffer(delq, "DROP VIEW %s;\n", qualrelname); |
| 17768 | |
| 17769 | if (dopt->binary_upgrade) |
| 17770 | binary_upgrade_set_pg_class_oids(fout, q, |
| 17771 | tbinfo->dobj.catId.oid, false); |
| 17772 | |
| 17773 | appendPQExpBuffer(q, "CREATE VIEW %s", qualrelname); |
| 17774 | |
| 17775 | if (tbinfo->dummy_view) |
| 17776 | result = createDummyViewAsClause(fout, tbinfo); |
| 17777 | else |
| 17778 | { |
no test coverage detected