* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.559 2009/12/22 23:27:41 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.560 2009/12/23 04:10:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static int collectComments(Archive *fout, CommentItem **items);
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
-static void dumpType(Archive *fout, TypeInfo *tinfo);
-static void dumpBaseType(Archive *fout, TypeInfo *tinfo);
-static void dumpEnumType(Archive *fout, TypeInfo *tinfo);
-static void dumpDomain(Archive *fout, TypeInfo *tinfo);
-static void dumpCompositeType(Archive *fout, TypeInfo *tinfo);
-static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo);
+static void dumpType(Archive *fout, TypeInfo *tyinfo);
+static void dumpBaseType(Archive *fout, TypeInfo *tyinfo);
+static void dumpEnumType(Archive *fout, TypeInfo *tyinfo);
+static void dumpDomain(Archive *fout, TypeInfo *tyinfo);
+static void dumpCompositeType(Archive *fout, TypeInfo *tyinfo);
+static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
static void dumpShellType(Archive *fout, ShellTypeInfo *stinfo);
static void dumpProcLang(Archive *fout, ProcLangInfo *plang);
static void dumpFunc(Archive *fout, FuncInfo *finfo);
const char *acls);
static void getDependencies(void);
-static void getDomainConstraints(TypeInfo *tinfo);
+static void getDomainConstraints(TypeInfo *tyinfo);
static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs);
* first to ensure the objType change is applied regardless of namespace etc.
*/
static void
-selectDumpableType(TypeInfo *tinfo)
+selectDumpableType(TypeInfo *tyinfo)
{
/* skip complex types, except for standalone composite types */
- if (OidIsValid(tinfo->typrelid) &&
- tinfo->typrelkind != RELKIND_COMPOSITE_TYPE)
+ if (OidIsValid(tyinfo->typrelid) &&
+ tyinfo->typrelkind != RELKIND_COMPOSITE_TYPE)
{
- tinfo->dobj.dump = false;
- tinfo->dobj.objType = DO_DUMMY_TYPE;
+ tyinfo->dobj.dump = false;
+ tyinfo->dobj.objType = DO_DUMMY_TYPE;
}
/* skip auto-generated array types */
- else if (tinfo->isArray)
+ else if (tyinfo->isArray)
{
- tinfo->dobj.dump = false;
- tinfo->dobj.objType = DO_DUMMY_TYPE;
+ tyinfo->dobj.dump = false;
+ tyinfo->dobj.objType = DO_DUMMY_TYPE;
}
/* dump only types in dumpable namespaces */
- else if (!tinfo->dobj.namespace->dobj.dump)
- tinfo->dobj.dump = false;
+ else if (!tyinfo->dobj.namespace->dobj.dump)
+ tyinfo->dobj.dump = false;
/* skip undefined placeholder types */
- else if (!tinfo->isDefined)
- tinfo->dobj.dump = false;
+ else if (!tyinfo->isDefined)
+ tyinfo->dobj.dump = false;
else
- tinfo->dobj.dump = true;
+ tyinfo->dobj.dump = true;
}
/*
int ntups;
int i;
PQExpBuffer query = createPQExpBuffer();
- TypeInfo *tinfo;
+ TypeInfo *tyinfo;
ShellTypeInfo *stinfo;
int i_tableoid;
int i_oid;
ntups = PQntuples(res);
- tinfo = (TypeInfo *) malloc(ntups * sizeof(TypeInfo));
+ tyinfo = (TypeInfo *) malloc(ntups * sizeof(TypeInfo));
i_tableoid = PQfnumber(res, "tableoid");
i_oid = PQfnumber(res, "oid");
for (i = 0; i < ntups; i++)
{
- tinfo[i].dobj.objType = DO_TYPE;
- tinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
- tinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
- AssignDumpId(&tinfo[i].dobj);
- tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
- tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
- tinfo[i].dobj.catId.oid);
- tinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
- tinfo[i].typelem = atooid(PQgetvalue(res, i, i_typelem));
- tinfo[i].typrelid = atooid(PQgetvalue(res, i, i_typrelid));
- tinfo[i].typrelkind = *PQgetvalue(res, i, i_typrelkind);
- tinfo[i].typtype = *PQgetvalue(res, i, i_typtype);
- tinfo[i].shellType = NULL;
+ tyinfo[i].dobj.objType = DO_TYPE;
+ tyinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
+ tyinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
+ AssignDumpId(&tyinfo[i].dobj);
+ tyinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname));
+ tyinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)),
+ tyinfo[i].dobj.catId.oid);
+ tyinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname));
+ tyinfo[i].typelem = atooid(PQgetvalue(res, i, i_typelem));
+ tyinfo[i].typrelid = atooid(PQgetvalue(res, i, i_typrelid));
+ tyinfo[i].typrelkind = *PQgetvalue(res, i, i_typrelkind);
+ tyinfo[i].typtype = *PQgetvalue(res, i, i_typtype);
+ tyinfo[i].shellType = NULL;
if (strcmp(PQgetvalue(res, i, i_typisdefined), "t") == 0)
- tinfo[i].isDefined = true;
+ tyinfo[i].isDefined = true;
else
- tinfo[i].isDefined = false;
+ tyinfo[i].isDefined = false;
if (strcmp(PQgetvalue(res, i, i_isarray), "t") == 0)
- tinfo[i].isArray = true;
+ tyinfo[i].isArray = true;
else
- tinfo[i].isArray = false;
+ tyinfo[i].isArray = false;
/* Decide whether we want to dump it */
- selectDumpableType(&tinfo[i]);
+ selectDumpableType(&tyinfo[i]);
/*
* If it's a domain, fetch info about its constraints, if any
*/
- tinfo[i].nDomChecks = 0;
- tinfo[i].domChecks = NULL;
- if (tinfo[i].dobj.dump && tinfo[i].typtype == TYPTYPE_DOMAIN)
- getDomainConstraints(&(tinfo[i]));
+ tyinfo[i].nDomChecks = 0;
+ tyinfo[i].domChecks = NULL;
+ if (tyinfo[i].dobj.dump && tyinfo[i].typtype == TYPTYPE_DOMAIN)
+ getDomainConstraints(&(tyinfo[i]));
/*
* If it's a base type, make a DumpableObject representing a shell
* should copy the base type's catId, but then it might capture the
* pg_depend entries for the type, which we don't want.
*/
- if (tinfo[i].dobj.dump && tinfo[i].typtype == TYPTYPE_BASE)
+ if (tyinfo[i].dobj.dump && tyinfo[i].typtype == TYPTYPE_BASE)
{
stinfo = (ShellTypeInfo *) malloc(sizeof(ShellTypeInfo));
stinfo->dobj.objType = DO_SHELL_TYPE;
stinfo->dobj.catId = nilCatalogId;
AssignDumpId(&stinfo->dobj);
- stinfo->dobj.name = strdup(tinfo[i].dobj.name);
- stinfo->dobj.namespace = tinfo[i].dobj.namespace;
- stinfo->baseType = &(tinfo[i]);
- tinfo[i].shellType = stinfo;
+ stinfo->dobj.name = strdup(tyinfo[i].dobj.name);
+ stinfo->dobj.namespace = tyinfo[i].dobj.namespace;
+ stinfo->baseType = &(tyinfo[i]);
+ tyinfo[i].shellType = stinfo;
/*
* Initially mark the shell type as not to be dumped. We'll only
if (funcInfo && funcInfo->dobj.dump)
{
/* base type depends on function */
- addObjectDependency(&tinfo[i].dobj,
+ addObjectDependency(&tyinfo[i].dobj,
funcInfo->dobj.dumpId);
/* function depends on shell type */
addObjectDependency(&funcInfo->dobj,
if (funcInfo && funcInfo->dobj.dump)
{
/* base type depends on function */
- addObjectDependency(&tinfo[i].dobj,
+ addObjectDependency(&tyinfo[i].dobj,
funcInfo->dobj.dumpId);
/* function depends on shell type */
addObjectDependency(&funcInfo->dobj,
}
}
- if (strlen(tinfo[i].rolname) == 0 && tinfo[i].isDefined)
+ if (strlen(tyinfo[i].rolname) == 0 && tyinfo[i].isDefined)
write_msg(NULL, "WARNING: owner of data type \"%s\" appears to be invalid\n",
- tinfo[i].dobj.name);
+ tyinfo[i].dobj.name);
}
*numTypes = ntups;
destroyPQExpBuffer(query);
- return tinfo;
+ return tyinfo;
}
/*
* Get info about constraints on a domain.
*/
static void
-getDomainConstraints(TypeInfo *tinfo)
+getDomainConstraints(TypeInfo *tyinfo)
{
int i;
ConstraintInfo *constrinfo;
* select appropriate schema to ensure names in constraint are properly
* qualified
*/
- selectSourceSchema(tinfo->dobj.namespace->dobj.name);
+ selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
query = createPQExpBuffer();
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%u'::pg_catalog.oid "
"ORDER BY conname",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
else
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
"'CHECK (' || consrc || ')' AS consrc "
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%u'::pg_catalog.oid "
"ORDER BY conname",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
constrinfo = (ConstraintInfo *) malloc(ntups * sizeof(ConstraintInfo));
- tinfo->nDomChecks = ntups;
- tinfo->domChecks = constrinfo;
+ tyinfo->nDomChecks = ntups;
+ tyinfo->domChecks = constrinfo;
for (i = 0; i < ntups; i++)
{
constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
AssignDumpId(&constrinfo[i].dobj);
constrinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname));
- constrinfo[i].dobj.namespace = tinfo->dobj.namespace;
+ constrinfo[i].dobj.namespace = tyinfo->dobj.namespace;
constrinfo[i].contable = NULL;
- constrinfo[i].condomain = tinfo;
+ constrinfo[i].condomain = tyinfo;
constrinfo[i].contype = 'c';
constrinfo[i].condef = strdup(PQgetvalue(res, i, i_consrc));
constrinfo[i].confrelid = InvalidOid;
* Make the domain depend on the constraint, ensuring it won't be
* output till any constraint dependencies are OK.
*/
- addObjectDependency(&tinfo->dobj,
+ addObjectDependency(&tyinfo->dobj,
constrinfo[i].dobj.dumpId);
}
* writes out to fout the queries to recreate a user-defined type
*/
static void
-dumpType(Archive *fout, TypeInfo *tinfo)
+dumpType(Archive *fout, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
- if (!tinfo->dobj.dump || dataOnly)
+ if (!tyinfo->dobj.dump || dataOnly)
return;
/* Dump out in proper style */
- if (tinfo->typtype == TYPTYPE_BASE)
- dumpBaseType(fout, tinfo);
- else if (tinfo->typtype == TYPTYPE_DOMAIN)
- dumpDomain(fout, tinfo);
- else if (tinfo->typtype == TYPTYPE_COMPOSITE)
- dumpCompositeType(fout, tinfo);
- else if (tinfo->typtype == TYPTYPE_ENUM)
- dumpEnumType(fout, tinfo);
+ if (tyinfo->typtype == TYPTYPE_BASE)
+ dumpBaseType(fout, tyinfo);
+ else if (tyinfo->typtype == TYPTYPE_DOMAIN)
+ dumpDomain(fout, tyinfo);
+ else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
+ dumpCompositeType(fout, tyinfo);
+ else if (tyinfo->typtype == TYPTYPE_ENUM)
+ dumpEnumType(fout, tyinfo);
}
/*
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
-dumpEnumType(Archive *fout, TypeInfo *tinfo)
+dumpEnumType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
char *label;
/* Set proper schema search path so regproc references list correctly */
- selectSourceSchema(tinfo->dobj.namespace->dobj.name);
+ selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
appendPQExpBuffer(query, "SELECT enumlabel FROM pg_catalog.pg_enum "
"WHERE enumtypid = '%u'"
"ORDER BY oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
/* should be at least 1 value */
if (num == 0)
{
- write_msg(NULL, "no label definitions found for enum ID %u\n", tinfo->dobj.catId.oid);
+ write_msg(NULL, "no label definitions found for enum ID %u\n", tyinfo->dobj.catId.oid);
exit_nicely();
}
* functions are generic and do not get dropped.
*/
appendPQExpBuffer(delq, "DROP TYPE %s.",
- fmtId(tinfo->dobj.namespace->dobj.name));
+ fmtId(tyinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
appendPQExpBuffer(q, "CREATE TYPE %s AS ENUM (\n",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
for (i = 0; i < num; i++)
{
label = PQgetvalue(res, i, 0);
}
appendPQExpBuffer(q, "\n);\n");
- ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->dobj.name,
- tinfo->dobj.namespace->dobj.name,
+ ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
+ tyinfo->dobj.name,
+ tyinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->rolname, false,
+ tyinfo->rolname, false,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
- tinfo->dobj.dependencies, tinfo->dobj.nDeps,
+ tyinfo->dobj.dependencies, tyinfo->dobj.nDeps,
NULL, NULL);
/* Dump Type Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
+ appendPQExpBuffer(q, "TYPE %s", fmtId(tyinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->rolname,
- tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
+ tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
+ tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
PQclear(res);
destroyPQExpBuffer(q);
* writes out to fout the queries to recreate a user-defined base type
*/
static void
-dumpBaseType(Archive *fout, TypeInfo *tinfo)
+dumpBaseType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
bool typdefault_is_literal = false;
/* Set proper schema search path so regproc references list correctly */
- selectSourceSchema(tinfo->dobj.namespace->dobj.name);
+ selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
/* Fetch type-specific details */
if (fout->remoteVersion >= 80400)
"pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 80300)
{
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 80000)
{
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 70400)
{
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 70300)
{
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 70200)
{
"NULL AS typdefaultbin, typdefault "
"FROM pg_type "
"WHERE oid = '%u'::oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 70100)
{
"NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type "
"WHERE oid = '%u'::oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
else
{
"NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type "
"WHERE oid = '%u'::oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
}
res = PQexec(g_conn, query->data);
* other way.
*/
appendPQExpBuffer(delq, "DROP TYPE %s.",
- fmtId(tinfo->dobj.namespace->dobj.name));
+ fmtId(tyinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s CASCADE;\n",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
appendPQExpBuffer(q,
"CREATE TYPE %s (\n"
" INTERNALLENGTH = %s",
- fmtId(tinfo->dobj.name),
+ fmtId(tyinfo->dobj.name),
(strcmp(typlen, "-1") == 0) ? "variable" : typlen);
if (fout->remoteVersion >= 70300)
appendPQExpBufferStr(q, typdefault);
}
- if (OidIsValid(tinfo->typelem))
+ if (OidIsValid(tyinfo->typelem))
{
char *elemType;
/* reselect schema in case changed by function dump */
- selectSourceSchema(tinfo->dobj.namespace->dobj.name);
- elemType = getFormattedTypeName(tinfo->typelem, zeroAsOpaque);
+ selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
+ elemType = getFormattedTypeName(tyinfo->typelem, zeroAsOpaque);
appendPQExpBuffer(q, ",\n ELEMENT = %s", elemType);
free(elemType);
}
appendPQExpBuffer(q, "\n);\n");
- ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->dobj.name,
- tinfo->dobj.namespace->dobj.name,
+ ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
+ tyinfo->dobj.name,
+ tyinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->rolname, false,
+ tyinfo->rolname, false,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
- tinfo->dobj.dependencies, tinfo->dobj.nDeps,
+ tyinfo->dobj.dependencies, tyinfo->dobj.nDeps,
NULL, NULL);
/* Dump Type Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
+ appendPQExpBuffer(q, "TYPE %s", fmtId(tyinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->rolname,
- tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
+ tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
+ tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
PQclear(res);
destroyPQExpBuffer(q);
* writes out to fout the queries to recreate a user-defined domain
*/
static void
-dumpDomain(Archive *fout, TypeInfo *tinfo)
+dumpDomain(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
bool typdefault_is_literal = false;
/* Set proper schema search path so type references list correctly */
- selectSourceSchema(tinfo->dobj.namespace->dobj.name);
+ selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
/* Fetch domain specific details */
/* We assume here that remoteVersion must be at least 70300 */
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
appendPQExpBuffer(q,
"CREATE DOMAIN %s AS %s",
- fmtId(tinfo->dobj.name),
+ fmtId(tyinfo->dobj.name),
typdefn);
if (typnotnull[0] == 't')
/*
* Add any CHECK constraints for the domain
*/
- for (i = 0; i < tinfo->nDomChecks; i++)
+ for (i = 0; i < tyinfo->nDomChecks; i++)
{
- ConstraintInfo *domcheck = &(tinfo->domChecks[i]);
+ ConstraintInfo *domcheck = &(tyinfo->domChecks[i]);
if (!domcheck->separate)
appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
* DROP must be fully qualified in case same name appears in pg_catalog
*/
appendPQExpBuffer(delq, "DROP DOMAIN %s.",
- fmtId(tinfo->dobj.namespace->dobj.name));
+ fmtId(tyinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
- ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->dobj.name,
- tinfo->dobj.namespace->dobj.name,
+ ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
+ tyinfo->dobj.name,
+ tyinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->rolname, false,
+ tyinfo->rolname, false,
"DOMAIN", SECTION_PRE_DATA,
q->data, delq->data, NULL,
- tinfo->dobj.dependencies, tinfo->dobj.nDeps,
+ tyinfo->dobj.dependencies, tyinfo->dobj.nDeps,
NULL, NULL);
/* Dump Domain Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "DOMAIN %s", fmtId(tinfo->dobj.name));
+ appendPQExpBuffer(q, "DOMAIN %s", fmtId(tyinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->rolname,
- tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
+ tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
+ tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
* composite type
*/
static void
-dumpCompositeType(Archive *fout, TypeInfo *tinfo)
+dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
int i;
/* Set proper schema search path so type references list correctly */
- selectSourceSchema(tinfo->dobj.namespace->dobj.name);
+ selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
/* Fetch type specific details */
/* We assume here that remoteVersion must be at least 70300 */
"AND a.attrelid = t.typrelid "
"AND NOT a.attisdropped "
"ORDER BY a.attnum ",
- tinfo->dobj.catId.oid);
+ tyinfo->dobj.catId.oid);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
i_atttypdefn = PQfnumber(res, "atttypdefn");
appendPQExpBuffer(q, "CREATE TYPE %s AS (",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
for (i = 0; i < ntups; i++)
{
* DROP must be fully qualified in case same name appears in pg_catalog
*/
appendPQExpBuffer(delq, "DROP TYPE %s.",
- fmtId(tinfo->dobj.namespace->dobj.name));
+ fmtId(tyinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
- ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
- tinfo->dobj.name,
- tinfo->dobj.namespace->dobj.name,
+ ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
+ tyinfo->dobj.name,
+ tyinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->rolname, false,
+ tyinfo->rolname, false,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
- tinfo->dobj.dependencies, tinfo->dobj.nDeps,
+ tyinfo->dobj.dependencies, tyinfo->dobj.nDeps,
NULL, NULL);
/* Dump Type Comments */
resetPQExpBuffer(q);
- appendPQExpBuffer(q, "TYPE %s", fmtId(tinfo->dobj.name));
+ appendPQExpBuffer(q, "TYPE %s", fmtId(tyinfo->dobj.name));
dumpComment(fout, q->data,
- tinfo->dobj.namespace->dobj.name, tinfo->rolname,
- tinfo->dobj.catId, 0, tinfo->dobj.dumpId);
+ tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
+ tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
PQclear(res);
destroyPQExpBuffer(q);
destroyPQExpBuffer(query);
/* Dump any per-column comments */
- dumpCompositeTypeColComments(fout, tinfo);
+ dumpCompositeTypeColComments(fout, tyinfo);
}
/*
* a user-defined stand-alone composite type
*/
static void
-dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
+dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo)
{
CommentItem *comments;
int ncomments;
"WHERE c.oid = '%u' AND c.oid = a.attrelid "
" AND NOT a.attisdropped "
"ORDER BY a.attnum ",
- tinfo->typrelid);
+ tyinfo->typrelid);
/* Fetch column attnames */
res = PQexec(g_conn, query->data);
/* Search for comments associated with type's pg_class OID */
ncomments = findComments(fout,
pgClassOid,
- tinfo->typrelid,
+ tyinfo->typrelid,
&comments);
/* If no comments exist, we're done */
resetPQExpBuffer(target);
appendPQExpBuffer(target, "COLUMN %s.",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
appendPQExpBuffer(target, "%s",
fmtId(attname));
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
- tinfo->dobj.namespace->dobj.name,
- NULL, tinfo->rolname,
+ tyinfo->dobj.namespace->dobj.name,
+ NULL, tyinfo->rolname,
false, "COMMENT", SECTION_NONE,
query->data, "", NULL,
- &(tinfo->dobj.dumpId), 1,
+ &(tyinfo->dobj.dumpId), 1,
NULL, NULL);
}
else if (coninfo->contype == 'c' && tbinfo == NULL)
{
/* CHECK constraint on a domain */
- TypeInfo *tinfo = coninfo->condomain;
+ TypeInfo *tyinfo = coninfo->condomain;
/* Ignore if not to be dumped separately */
if (coninfo->separate)
{
appendPQExpBuffer(q, "ALTER DOMAIN %s\n",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
appendPQExpBuffer(q, " ADD CONSTRAINT %s %s;\n",
fmtId(coninfo->dobj.name),
coninfo->condef);
* pg_catalog
*/
appendPQExpBuffer(delq, "ALTER DOMAIN %s.",
- fmtId(tinfo->dobj.namespace->dobj.name));
+ fmtId(tyinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s ",
- fmtId(tinfo->dobj.name));
+ fmtId(tyinfo->dobj.name));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(coninfo->dobj.name));
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
coninfo->dobj.name,
- tinfo->dobj.namespace->dobj.name,
+ tyinfo->dobj.namespace->dobj.name,
NULL,
- tinfo->rolname, false,
+ tyinfo->rolname, false,
"CHECK CONSTRAINT", SECTION_POST_DATA,
q->data, delq->data, NULL,
coninfo->dobj.dependencies, coninfo->dobj.nDeps,