* dumpSubscription * dump the definition of the given subscription */
| 4904 | * dump the definition of the given subscription |
| 4905 | */ |
| 4906 | static void |
| 4907 | dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo) |
| 4908 | { |
| 4909 | PQExpBuffer delq; |
| 4910 | PQExpBuffer query; |
| 4911 | PQExpBuffer publications; |
| 4912 | char *qsubname; |
| 4913 | char **pubnames = NULL; |
| 4914 | int npubnames = 0; |
| 4915 | int i; |
| 4916 | |
| 4917 | if (!(subinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)) |
| 4918 | return; |
| 4919 | |
| 4920 | delq = createPQExpBuffer(); |
| 4921 | query = createPQExpBuffer(); |
| 4922 | |
| 4923 | qsubname = pg_strdup(fmtId(subinfo->dobj.name)); |
| 4924 | |
| 4925 | appendPQExpBuffer(delq, "DROP SUBSCRIPTION %s;\n", |
| 4926 | qsubname); |
| 4927 | |
| 4928 | appendPQExpBuffer(query, "CREATE SUBSCRIPTION %s CONNECTION ", |
| 4929 | qsubname); |
| 4930 | appendStringLiteralAH(query, subinfo->subconninfo, fout); |
| 4931 | |
| 4932 | /* Build list of quoted publications and append them to query. */ |
| 4933 | if (!parsePGArray(subinfo->subpublications, &pubnames, &npubnames)) |
| 4934 | fatal("could not parse subpublications array"); |
| 4935 | |
| 4936 | publications = createPQExpBuffer(); |
| 4937 | for (i = 0; i < npubnames; i++) |
| 4938 | { |
| 4939 | if (i > 0) |
| 4940 | appendPQExpBufferStr(publications, ", "); |
| 4941 | |
| 4942 | appendPQExpBufferStr(publications, fmtId(pubnames[i])); |
| 4943 | } |
| 4944 | |
| 4945 | appendPQExpBuffer(query, " PUBLICATION %s WITH (connect = false, slot_name = ", publications->data); |
| 4946 | if (subinfo->subslotname) |
| 4947 | appendStringLiteralAH(query, subinfo->subslotname, fout); |
| 4948 | else |
| 4949 | appendPQExpBufferStr(query, "NONE"); |
| 4950 | |
| 4951 | if (strcmp(subinfo->subbinary, "t") == 0) |
| 4952 | appendPQExpBufferStr(query, ", binary = true"); |
| 4953 | |
| 4954 | if (strcmp(subinfo->substream, "f") != 0) |
| 4955 | appendPQExpBufferStr(query, ", streaming = on"); |
| 4956 | |
| 4957 | if (strcmp(subinfo->subsynccommit, "off") != 0) |
| 4958 | appendPQExpBuffer(query, ", synchronous_commit = %s", fmtId(subinfo->subsynccommit)); |
| 4959 | |
| 4960 | appendPQExpBufferStr(query, ");\n"); |
| 4961 | |
| 4962 | ArchiveEntry(fout, subinfo->dobj.catId, subinfo->dobj.dumpId, |
| 4963 | ARCHIVE_OPTS(.tag = subinfo->dobj.name, |
no test coverage detected