Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not dump default babelfishpg_telemetry schema #226

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions src/bin/pg_dump/dump_babel_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ bbf_selectDumpableObject(DumpableObject *dobj, Archive *fout)
ExtensionInfo *ext = findOwningExtension(cast->dobj.catId);

/* Skip if cast is not a member of babelfish extension */
if (ext == NULL || strcmp(ext->dobj.name, "babelfishpg_common") != 0)
if (ext == NULL || strncmp(ext->dobj.name, "babelfishpg_common", 18) != 0)
rishabhtanwar29 marked this conversation as resolved.
Show resolved Hide resolved
return;

sTypeInfo = findTypeByOid(cast->castsource);
Expand All @@ -328,11 +328,11 @@ bbf_selectDumpableObject(DumpableObject *dobj, Archive *fout)
if (sTypeInfo && tTypeInfo &&
sTypeInfo->dobj.namespace &&
tTypeInfo->dobj.namespace &&
strcmp(sTypeInfo->dobj.namespace->dobj.name, "pg_catalog") == 0 &&
strcmp(tTypeInfo->dobj.namespace->dobj.name, "sys") == 0 &&
strcmp(sTypeInfo->dobj.name, "bool") == 0 &&
(strcmp(tTypeInfo->dobj.name, "bpchar") == 0 ||
strcmp(tTypeInfo->dobj.name, "varchar") == 0))
strncmp(sTypeInfo->dobj.namespace->dobj.name, "pg_catalog", 10) == 0 &&
strncmp(tTypeInfo->dobj.namespace->dobj.name, "sys", 3) == 0 &&
strncmp(sTypeInfo->dobj.name, "bool", 4) == 0 &&
(strncmp(tTypeInfo->dobj.name, "bpchar", 6) == 0 ||
strncmp(tTypeInfo->dobj.name, "varchar", 7) == 0))
cast->dobj.dump = DUMP_COMPONENT_NONE;
}
break;
Expand All @@ -354,10 +354,10 @@ bbf_selectDumpableObject(DumpableObject *dobj, Archive *fout)
* will always dump it.
*/
if (tbinfo->dobj.namespace &&
(strcmp(tbinfo->dobj.namespace->dobj.name, "master_dbo") == 0 ||
strcmp(tbinfo->dobj.namespace->dobj.name, "msdb_dbo") == 0 ||
strcmp(tbinfo->dobj.namespace->dobj.name, "tempdb_dbo") == 0) &&
strcmp(tbinfo->dobj.name, "sysdatabases") == 0)
(strncmp(tbinfo->dobj.namespace->dobj.name, "master_dbo", 10) == 0 ||
strncmp(tbinfo->dobj.namespace->dobj.name, "msdb_dbo", 8) == 0 ||
strncmp(tbinfo->dobj.namespace->dobj.name, "tempdb_dbo", 10) == 0) &&
strncmp(tbinfo->dobj.name, "sysdatabases", 12) == 0)
{
tbinfo->dobj.dump = DUMP_COMPONENT_NONE;
break;
Expand All @@ -371,8 +371,8 @@ bbf_selectDumpableObject(DumpableObject *dobj, Archive *fout)
case RELKIND_SEQUENCE:
{
if (dobj->namespace &&
strcmp(dobj->namespace->dobj.name, "sys") == 0 &&
strcmp(dobj->name, "babelfish_db_seq") == 0)
strncmp(dobj->namespace->dobj.name, "sys", 3) == 0 &&
strncmp(dobj->name, "babelfish_db_seq", 16) == 0)
dobj->dump &= ~DUMP_COMPONENT_ACL;
}
break;
Expand All @@ -397,14 +397,24 @@ bbf_selectDumpableObject(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
return;

/* Do not dump the definition of default babelfish schemas */
if (strcmp(nsinfo->dobj.name, "master_dbo") == 0 ||
strcmp(nsinfo->dobj.name, "master_guest") == 0 ||
strcmp(nsinfo->dobj.name, "msdb_dbo") == 0 ||
strcmp(nsinfo->dobj.name, "msdb_guest") == 0 ||
strcmp(nsinfo->dobj.name, "tempdb_dbo") == 0 ||
strcmp(nsinfo->dobj.name, "tempdb_guest") == 0)
/*
* Do not dump the definition of default babelfish schemas but
* their contained objects will be dumped.
*/
if (strncmp(nsinfo->dobj.name, "master_dbo", 10) == 0 ||
strncmp(nsinfo->dobj.name, "master_guest", 12) == 0 ||
strncmp(nsinfo->dobj.name, "msdb_dbo", 8) == 0 ||
strncmp(nsinfo->dobj.name, "msdb_guest", 10) == 0 ||
strncmp(nsinfo->dobj.name, "tempdb_dbo", 10) == 0 ||
strncmp(nsinfo->dobj.name, "tempdb_guest", 12) == 0)
nsinfo->dobj.dump &= ~DUMP_COMPONENT_DEFINITION;

/*
* Do not dump any components of the schemas which get created as
* part of CREATE EXTENSION babelfish... command.
*/
if (strncmp(nsinfo->dobj.name, "babelfishpg_telemetry", 21) == 0)
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
}
break;
case DO_EXTENSION:
Expand All @@ -415,7 +425,7 @@ bbf_selectDumpableObject(DumpableObject *dobj, Archive *fout)
return;

if (strncmp(extinfo->dobj.name, "babelfishpg", 11) == 0)
extinfo->dobj.dump &= ~DUMP_COMPONENT_DEFINITION;
extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_NONE;
}
break;
case DO_FUNC:
Expand Down
Loading