Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b6839080
Commit
b6839080
authored
Dec 23, 2009
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename pg_dump.c TypeInfo variable tinfo to tyinfo, for clarity.
parent
cfc5008a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
157 deletions
+157
-157
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+157
-157
No files found.
src/bin/pg_dump/pg_dump.c
View file @
b6839080
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* by PostgreSQL
* by PostgreSQL
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.5
59 2009/12/22 23:27:41 petere
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.5
60 2009/12/23 04:10:50 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -131,12 +131,12 @@ static int findComments(Archive *fout, Oid classoid, Oid objoid,
...
@@ -131,12 +131,12 @@ static int findComments(Archive *fout, Oid classoid, Oid objoid,
static
int
collectComments
(
Archive
*
fout
,
CommentItem
**
items
);
static
int
collectComments
(
Archive
*
fout
,
CommentItem
**
items
);
static
void
dumpDumpableObject
(
Archive
*
fout
,
DumpableObject
*
dobj
);
static
void
dumpDumpableObject
(
Archive
*
fout
,
DumpableObject
*
dobj
);
static
void
dumpNamespace
(
Archive
*
fout
,
NamespaceInfo
*
nspinfo
);
static
void
dumpNamespace
(
Archive
*
fout
,
NamespaceInfo
*
nspinfo
);
static
void
dumpType
(
Archive
*
fout
,
TypeInfo
*
tinfo
);
static
void
dumpType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
);
static
void
dumpBaseType
(
Archive
*
fout
,
TypeInfo
*
tinfo
);
static
void
dumpBaseType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
);
static
void
dumpEnumType
(
Archive
*
fout
,
TypeInfo
*
tinfo
);
static
void
dumpEnumType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
);
static
void
dumpDomain
(
Archive
*
fout
,
TypeInfo
*
tinfo
);
static
void
dumpDomain
(
Archive
*
fout
,
TypeInfo
*
t
y
info
);
static
void
dumpCompositeType
(
Archive
*
fout
,
TypeInfo
*
tinfo
);
static
void
dumpCompositeType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
);
static
void
dumpCompositeTypeColComments
(
Archive
*
fout
,
TypeInfo
*
tinfo
);
static
void
dumpCompositeTypeColComments
(
Archive
*
fout
,
TypeInfo
*
t
y
info
);
static
void
dumpShellType
(
Archive
*
fout
,
ShellTypeInfo
*
stinfo
);
static
void
dumpShellType
(
Archive
*
fout
,
ShellTypeInfo
*
stinfo
);
static
void
dumpProcLang
(
Archive
*
fout
,
ProcLangInfo
*
plang
);
static
void
dumpProcLang
(
Archive
*
fout
,
ProcLangInfo
*
plang
);
static
void
dumpFunc
(
Archive
*
fout
,
FuncInfo
*
finfo
);
static
void
dumpFunc
(
Archive
*
fout
,
FuncInfo
*
finfo
);
...
@@ -172,7 +172,7 @@ static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
...
@@ -172,7 +172,7 @@ static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const
char
*
acls
);
const
char
*
acls
);
static
void
getDependencies
(
void
);
static
void
getDependencies
(
void
);
static
void
getDomainConstraints
(
TypeInfo
*
tinfo
);
static
void
getDomainConstraints
(
TypeInfo
*
t
y
info
);
static
void
getTableData
(
TableInfo
*
tblinfo
,
int
numTables
,
bool
oids
);
static
void
getTableData
(
TableInfo
*
tblinfo
,
int
numTables
,
bool
oids
);
static
void
getTableDataFKConstraints
(
void
);
static
void
getTableDataFKConstraints
(
void
);
static
char
*
format_function_arguments
(
FuncInfo
*
finfo
,
char
*
funcargs
);
static
char
*
format_function_arguments
(
FuncInfo
*
finfo
,
char
*
funcargs
);
...
@@ -1023,33 +1023,33 @@ selectDumpableTable(TableInfo *tbinfo)
...
@@ -1023,33 +1023,33 @@ selectDumpableTable(TableInfo *tbinfo)
* first to ensure the objType change is applied regardless of namespace etc.
* first to ensure the objType change is applied regardless of namespace etc.
*/
*/
static
void
static
void
selectDumpableType
(
TypeInfo
*
tinfo
)
selectDumpableType
(
TypeInfo
*
t
y
info
)
{
{
/* skip complex types, except for standalone composite types */
/* skip complex types, except for standalone composite types */
if
(
OidIsValid
(
tinfo
->
typrelid
)
&&
if
(
OidIsValid
(
t
y
info
->
typrelid
)
&&
tinfo
->
typrelkind
!=
RELKIND_COMPOSITE_TYPE
)
t
y
info
->
typrelkind
!=
RELKIND_COMPOSITE_TYPE
)
{
{
tinfo
->
dobj
.
dump
=
false
;
t
y
info
->
dobj
.
dump
=
false
;
tinfo
->
dobj
.
objType
=
DO_DUMMY_TYPE
;
t
y
info
->
dobj
.
objType
=
DO_DUMMY_TYPE
;
}
}
/* skip auto-generated array types */
/* skip auto-generated array types */
else
if
(
tinfo
->
isArray
)
else
if
(
t
y
info
->
isArray
)
{
{
tinfo
->
dobj
.
dump
=
false
;
t
y
info
->
dobj
.
dump
=
false
;
tinfo
->
dobj
.
objType
=
DO_DUMMY_TYPE
;
t
y
info
->
dobj
.
objType
=
DO_DUMMY_TYPE
;
}
}
/* dump only types in dumpable namespaces */
/* dump only types in dumpable namespaces */
else
if
(
!
tinfo
->
dobj
.
namespace
->
dobj
.
dump
)
else
if
(
!
t
y
info
->
dobj
.
namespace
->
dobj
.
dump
)
tinfo
->
dobj
.
dump
=
false
;
t
y
info
->
dobj
.
dump
=
false
;
/* skip undefined placeholder types */
/* skip undefined placeholder types */
else
if
(
!
tinfo
->
isDefined
)
else
if
(
!
t
y
info
->
isDefined
)
tinfo
->
dobj
.
dump
=
false
;
t
y
info
->
dobj
.
dump
=
false
;
else
else
tinfo
->
dobj
.
dump
=
true
;
t
y
info
->
dobj
.
dump
=
true
;
}
}
/*
/*
...
@@ -2340,7 +2340,7 @@ getTypes(int *numTypes)
...
@@ -2340,7 +2340,7 @@ getTypes(int *numTypes)
int
ntups
;
int
ntups
;
int
i
;
int
i
;
PQExpBuffer
query
=
createPQExpBuffer
();
PQExpBuffer
query
=
createPQExpBuffer
();
TypeInfo
*
tinfo
;
TypeInfo
*
t
y
info
;
ShellTypeInfo
*
stinfo
;
ShellTypeInfo
*
stinfo
;
int
i_tableoid
;
int
i_tableoid
;
int
i_oid
;
int
i_oid
;
...
@@ -2440,7 +2440,7 @@ getTypes(int *numTypes)
...
@@ -2440,7 +2440,7 @@ getTypes(int *numTypes)
ntups
=
PQntuples
(
res
);
ntups
=
PQntuples
(
res
);
tinfo
=
(
TypeInfo
*
)
malloc
(
ntups
*
sizeof
(
TypeInfo
));
t
y
info
=
(
TypeInfo
*
)
malloc
(
ntups
*
sizeof
(
TypeInfo
));
i_tableoid
=
PQfnumber
(
res
,
"tableoid"
);
i_tableoid
=
PQfnumber
(
res
,
"tableoid"
);
i_oid
=
PQfnumber
(
res
,
"oid"
);
i_oid
=
PQfnumber
(
res
,
"oid"
);
...
@@ -2458,40 +2458,40 @@ getTypes(int *numTypes)
...
@@ -2458,40 +2458,40 @@ getTypes(int *numTypes)
for
(
i
=
0
;
i
<
ntups
;
i
++
)
for
(
i
=
0
;
i
<
ntups
;
i
++
)
{
{
tinfo
[
i
].
dobj
.
objType
=
DO_TYPE
;
t
y
info
[
i
].
dobj
.
objType
=
DO_TYPE
;
tinfo
[
i
].
dobj
.
catId
.
tableoid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_tableoid
));
t
y
info
[
i
].
dobj
.
catId
.
tableoid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_tableoid
));
tinfo
[
i
].
dobj
.
catId
.
oid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_oid
));
t
y
info
[
i
].
dobj
.
catId
.
oid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_oid
));
AssignDumpId
(
&
tinfo
[
i
].
dobj
);
AssignDumpId
(
&
t
y
info
[
i
].
dobj
);
tinfo
[
i
].
dobj
.
name
=
strdup
(
PQgetvalue
(
res
,
i
,
i_typname
));
t
y
info
[
i
].
dobj
.
name
=
strdup
(
PQgetvalue
(
res
,
i
,
i_typname
));
tinfo
[
i
].
dobj
.
namespace
=
findNamespace
(
atooid
(
PQgetvalue
(
res
,
i
,
i_typnamespace
)),
t
y
info
[
i
].
dobj
.
namespace
=
findNamespace
(
atooid
(
PQgetvalue
(
res
,
i
,
i_typnamespace
)),
tinfo
[
i
].
dobj
.
catId
.
oid
);
t
y
info
[
i
].
dobj
.
catId
.
oid
);
tinfo
[
i
].
rolname
=
strdup
(
PQgetvalue
(
res
,
i
,
i_rolname
));
t
y
info
[
i
].
rolname
=
strdup
(
PQgetvalue
(
res
,
i
,
i_rolname
));
tinfo
[
i
].
typelem
=
atooid
(
PQgetvalue
(
res
,
i
,
i_typelem
));
t
y
info
[
i
].
typelem
=
atooid
(
PQgetvalue
(
res
,
i
,
i_typelem
));
tinfo
[
i
].
typrelid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_typrelid
));
t
y
info
[
i
].
typrelid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_typrelid
));
tinfo
[
i
].
typrelkind
=
*
PQgetvalue
(
res
,
i
,
i_typrelkind
);
t
y
info
[
i
].
typrelkind
=
*
PQgetvalue
(
res
,
i
,
i_typrelkind
);
tinfo
[
i
].
typtype
=
*
PQgetvalue
(
res
,
i
,
i_typtype
);
t
y
info
[
i
].
typtype
=
*
PQgetvalue
(
res
,
i
,
i_typtype
);
tinfo
[
i
].
shellType
=
NULL
;
t
y
info
[
i
].
shellType
=
NULL
;
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
i_typisdefined
),
"t"
)
==
0
)
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
i_typisdefined
),
"t"
)
==
0
)
tinfo
[
i
].
isDefined
=
true
;
t
y
info
[
i
].
isDefined
=
true
;
else
else
tinfo
[
i
].
isDefined
=
false
;
t
y
info
[
i
].
isDefined
=
false
;
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
i_isarray
),
"t"
)
==
0
)
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
i_isarray
),
"t"
)
==
0
)
tinfo
[
i
].
isArray
=
true
;
t
y
info
[
i
].
isArray
=
true
;
else
else
tinfo
[
i
].
isArray
=
false
;
t
y
info
[
i
].
isArray
=
false
;
/* Decide whether we want to dump it */
/* Decide whether we want to dump it */
selectDumpableType
(
&
tinfo
[
i
]);
selectDumpableType
(
&
t
y
info
[
i
]);
/*
/*
* If it's a domain, fetch info about its constraints, if any
* If it's a domain, fetch info about its constraints, if any
*/
*/
tinfo
[
i
].
nDomChecks
=
0
;
t
y
info
[
i
].
nDomChecks
=
0
;
tinfo
[
i
].
domChecks
=
NULL
;
t
y
info
[
i
].
domChecks
=
NULL
;
if
(
t
info
[
i
].
dobj
.
dump
&&
t
info
[
i
].
typtype
==
TYPTYPE_DOMAIN
)
if
(
t
yinfo
[
i
].
dobj
.
dump
&&
ty
info
[
i
].
typtype
==
TYPTYPE_DOMAIN
)
getDomainConstraints
(
&
(
tinfo
[
i
]));
getDomainConstraints
(
&
(
t
y
info
[
i
]));
/*
/*
* If it's a base type, make a DumpableObject representing a shell
* If it's a base type, make a DumpableObject representing a shell
...
@@ -2502,16 +2502,16 @@ getTypes(int *numTypes)
...
@@ -2502,16 +2502,16 @@ getTypes(int *numTypes)
* should copy the base type's catId, but then it might capture the
* should copy the base type's catId, but then it might capture the
* pg_depend entries for the type, which we don't want.
* pg_depend entries for the type, which we don't want.
*/
*/
if
(
t
info
[
i
].
dobj
.
dump
&&
t
info
[
i
].
typtype
==
TYPTYPE_BASE
)
if
(
t
yinfo
[
i
].
dobj
.
dump
&&
ty
info
[
i
].
typtype
==
TYPTYPE_BASE
)
{
{
stinfo
=
(
ShellTypeInfo
*
)
malloc
(
sizeof
(
ShellTypeInfo
));
stinfo
=
(
ShellTypeInfo
*
)
malloc
(
sizeof
(
ShellTypeInfo
));
stinfo
->
dobj
.
objType
=
DO_SHELL_TYPE
;
stinfo
->
dobj
.
objType
=
DO_SHELL_TYPE
;
stinfo
->
dobj
.
catId
=
nilCatalogId
;
stinfo
->
dobj
.
catId
=
nilCatalogId
;
AssignDumpId
(
&
stinfo
->
dobj
);
AssignDumpId
(
&
stinfo
->
dobj
);
stinfo
->
dobj
.
name
=
strdup
(
tinfo
[
i
].
dobj
.
name
);
stinfo
->
dobj
.
name
=
strdup
(
t
y
info
[
i
].
dobj
.
name
);
stinfo
->
dobj
.
namespace
=
tinfo
[
i
].
dobj
.
namespace
;
stinfo
->
dobj
.
namespace
=
t
y
info
[
i
].
dobj
.
namespace
;
stinfo
->
baseType
=
&
(
tinfo
[
i
]);
stinfo
->
baseType
=
&
(
t
y
info
[
i
]);
tinfo
[
i
].
shellType
=
stinfo
;
t
y
info
[
i
].
shellType
=
stinfo
;
/*
/*
* Initially mark the shell type as not to be dumped. We'll only
* Initially mark the shell type as not to be dumped. We'll only
...
@@ -2539,7 +2539,7 @@ getTypes(int *numTypes)
...
@@ -2539,7 +2539,7 @@ getTypes(int *numTypes)
if
(
funcInfo
&&
funcInfo
->
dobj
.
dump
)
if
(
funcInfo
&&
funcInfo
->
dobj
.
dump
)
{
{
/* base type depends on function */
/* base type depends on function */
addObjectDependency
(
&
tinfo
[
i
].
dobj
,
addObjectDependency
(
&
t
y
info
[
i
].
dobj
,
funcInfo
->
dobj
.
dumpId
);
funcInfo
->
dobj
.
dumpId
);
/* function depends on shell type */
/* function depends on shell type */
addObjectDependency
(
&
funcInfo
->
dobj
,
addObjectDependency
(
&
funcInfo
->
dobj
,
...
@@ -2552,7 +2552,7 @@ getTypes(int *numTypes)
...
@@ -2552,7 +2552,7 @@ getTypes(int *numTypes)
if
(
funcInfo
&&
funcInfo
->
dobj
.
dump
)
if
(
funcInfo
&&
funcInfo
->
dobj
.
dump
)
{
{
/* base type depends on function */
/* base type depends on function */
addObjectDependency
(
&
tinfo
[
i
].
dobj
,
addObjectDependency
(
&
t
y
info
[
i
].
dobj
,
funcInfo
->
dobj
.
dumpId
);
funcInfo
->
dobj
.
dumpId
);
/* function depends on shell type */
/* function depends on shell type */
addObjectDependency
(
&
funcInfo
->
dobj
,
addObjectDependency
(
&
funcInfo
->
dobj
,
...
@@ -2563,9 +2563,9 @@ getTypes(int *numTypes)
...
@@ -2563,9 +2563,9 @@ getTypes(int *numTypes)
}
}
}
}
if
(
strlen
(
t
info
[
i
].
rolname
)
==
0
&&
t
info
[
i
].
isDefined
)
if
(
strlen
(
t
yinfo
[
i
].
rolname
)
==
0
&&
ty
info
[
i
].
isDefined
)
write_msg
(
NULL
,
"WARNING: owner of data type
\"
%s
\"
appears to be invalid
\n
"
,
write_msg
(
NULL
,
"WARNING: owner of data type
\"
%s
\"
appears to be invalid
\n
"
,
tinfo
[
i
].
dobj
.
name
);
t
y
info
[
i
].
dobj
.
name
);
}
}
*
numTypes
=
ntups
;
*
numTypes
=
ntups
;
...
@@ -2574,7 +2574,7 @@ getTypes(int *numTypes)
...
@@ -2574,7 +2574,7 @@ getTypes(int *numTypes)
destroyPQExpBuffer
(
query
);
destroyPQExpBuffer
(
query
);
return
tinfo
;
return
t
y
info
;
}
}
/*
/*
...
@@ -4119,7 +4119,7 @@ getConstraints(TableInfo tblinfo[], int numTables)
...
@@ -4119,7 +4119,7 @@ getConstraints(TableInfo tblinfo[], int numTables)
* Get info about constraints on a domain.
* Get info about constraints on a domain.
*/
*/
static
void
static
void
getDomainConstraints
(
TypeInfo
*
tinfo
)
getDomainConstraints
(
TypeInfo
*
t
y
info
)
{
{
int
i
;
int
i
;
ConstraintInfo
*
constrinfo
;
ConstraintInfo
*
constrinfo
;
...
@@ -4139,7 +4139,7 @@ getDomainConstraints(TypeInfo *tinfo)
...
@@ -4139,7 +4139,7 @@ getDomainConstraints(TypeInfo *tinfo)
* select appropriate schema to ensure names in constraint are properly
* select appropriate schema to ensure names in constraint are properly
* qualified
* qualified
*/
*/
selectSourceSchema
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
);
selectSourceSchema
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
);
query
=
createPQExpBuffer
();
query
=
createPQExpBuffer
();
...
@@ -4149,14 +4149,14 @@ getDomainConstraints(TypeInfo *tinfo)
...
@@ -4149,14 +4149,14 @@ getDomainConstraints(TypeInfo *tinfo)
"FROM pg_catalog.pg_constraint "
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%u'::pg_catalog.oid "
"WHERE contypid = '%u'::pg_catalog.oid "
"ORDER BY conname"
,
"ORDER BY conname"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
else
else
appendPQExpBuffer
(
query
,
"SELECT tableoid, oid, conname, "
appendPQExpBuffer
(
query
,
"SELECT tableoid, oid, conname, "
"'CHECK (' || consrc || ')' AS consrc "
"'CHECK (' || consrc || ')' AS consrc "
"FROM pg_catalog.pg_constraint "
"FROM pg_catalog.pg_constraint "
"WHERE contypid = '%u'::pg_catalog.oid "
"WHERE contypid = '%u'::pg_catalog.oid "
"ORDER BY conname"
,
"ORDER BY conname"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
res
=
PQexec
(
g_conn
,
query
->
data
);
res
=
PQexec
(
g_conn
,
query
->
data
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
...
@@ -4170,8 +4170,8 @@ getDomainConstraints(TypeInfo *tinfo)
...
@@ -4170,8 +4170,8 @@ getDomainConstraints(TypeInfo *tinfo)
constrinfo
=
(
ConstraintInfo
*
)
malloc
(
ntups
*
sizeof
(
ConstraintInfo
));
constrinfo
=
(
ConstraintInfo
*
)
malloc
(
ntups
*
sizeof
(
ConstraintInfo
));
tinfo
->
nDomChecks
=
ntups
;
t
y
info
->
nDomChecks
=
ntups
;
tinfo
->
domChecks
=
constrinfo
;
t
y
info
->
domChecks
=
constrinfo
;
for
(
i
=
0
;
i
<
ntups
;
i
++
)
for
(
i
=
0
;
i
<
ntups
;
i
++
)
{
{
...
@@ -4180,9 +4180,9 @@ getDomainConstraints(TypeInfo *tinfo)
...
@@ -4180,9 +4180,9 @@ getDomainConstraints(TypeInfo *tinfo)
constrinfo
[
i
].
dobj
.
catId
.
oid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_oid
));
constrinfo
[
i
].
dobj
.
catId
.
oid
=
atooid
(
PQgetvalue
(
res
,
i
,
i_oid
));
AssignDumpId
(
&
constrinfo
[
i
].
dobj
);
AssignDumpId
(
&
constrinfo
[
i
].
dobj
);
constrinfo
[
i
].
dobj
.
name
=
strdup
(
PQgetvalue
(
res
,
i
,
i_conname
));
constrinfo
[
i
].
dobj
.
name
=
strdup
(
PQgetvalue
(
res
,
i
,
i_conname
));
constrinfo
[
i
].
dobj
.
namespace
=
tinfo
->
dobj
.
namespace
;
constrinfo
[
i
].
dobj
.
namespace
=
t
y
info
->
dobj
.
namespace
;
constrinfo
[
i
].
contable
=
NULL
;
constrinfo
[
i
].
contable
=
NULL
;
constrinfo
[
i
].
condomain
=
tinfo
;
constrinfo
[
i
].
condomain
=
t
y
info
;
constrinfo
[
i
].
contype
=
'c'
;
constrinfo
[
i
].
contype
=
'c'
;
constrinfo
[
i
].
condef
=
strdup
(
PQgetvalue
(
res
,
i
,
i_consrc
));
constrinfo
[
i
].
condef
=
strdup
(
PQgetvalue
(
res
,
i
,
i_consrc
));
constrinfo
[
i
].
confrelid
=
InvalidOid
;
constrinfo
[
i
].
confrelid
=
InvalidOid
;
...
@@ -4196,7 +4196,7 @@ getDomainConstraints(TypeInfo *tinfo)
...
@@ -4196,7 +4196,7 @@ getDomainConstraints(TypeInfo *tinfo)
* Make the domain depend on the constraint, ensuring it won't be
* Make the domain depend on the constraint, ensuring it won't be
* output till any constraint dependencies are OK.
* output till any constraint dependencies are OK.
*/
*/
addObjectDependency
(
&
tinfo
->
dobj
,
addObjectDependency
(
&
t
y
info
->
dobj
,
constrinfo
[
i
].
dobj
.
dumpId
);
constrinfo
[
i
].
dobj
.
dumpId
);
}
}
...
@@ -6368,21 +6368,21 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
...
@@ -6368,21 +6368,21 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
* writes out to fout the queries to recreate a user-defined type
* writes out to fout the queries to recreate a user-defined type
*/
*/
static
void
static
void
dumpType
(
Archive
*
fout
,
TypeInfo
*
tinfo
)
dumpType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
)
{
{
/* Skip if not to be dumped */
/* Skip if not to be dumped */
if
(
!
tinfo
->
dobj
.
dump
||
dataOnly
)
if
(
!
t
y
info
->
dobj
.
dump
||
dataOnly
)
return
;
return
;
/* Dump out in proper style */
/* Dump out in proper style */
if
(
tinfo
->
typtype
==
TYPTYPE_BASE
)
if
(
t
y
info
->
typtype
==
TYPTYPE_BASE
)
dumpBaseType
(
fout
,
tinfo
);
dumpBaseType
(
fout
,
t
y
info
);
else
if
(
tinfo
->
typtype
==
TYPTYPE_DOMAIN
)
else
if
(
t
y
info
->
typtype
==
TYPTYPE_DOMAIN
)
dumpDomain
(
fout
,
tinfo
);
dumpDomain
(
fout
,
t
y
info
);
else
if
(
tinfo
->
typtype
==
TYPTYPE_COMPOSITE
)
else
if
(
t
y
info
->
typtype
==
TYPTYPE_COMPOSITE
)
dumpCompositeType
(
fout
,
tinfo
);
dumpCompositeType
(
fout
,
t
y
info
);
else
if
(
tinfo
->
typtype
==
TYPTYPE_ENUM
)
else
if
(
t
y
info
->
typtype
==
TYPTYPE_ENUM
)
dumpEnumType
(
fout
,
tinfo
);
dumpEnumType
(
fout
,
t
y
info
);
}
}
/*
/*
...
@@ -6390,7 +6390,7 @@ dumpType(Archive *fout, TypeInfo *tinfo)
...
@@ -6390,7 +6390,7 @@ dumpType(Archive *fout, TypeInfo *tinfo)
* writes out to fout the queries to recreate a user-defined enum type
* writes out to fout the queries to recreate a user-defined enum type
*/
*/
static
void
static
void
dumpEnumType
(
Archive
*
fout
,
TypeInfo
*
tinfo
)
dumpEnumType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
)
{
{
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
...
@@ -6401,12 +6401,12 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
...
@@ -6401,12 +6401,12 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
char
*
label
;
char
*
label
;
/* Set proper schema search path so regproc references list correctly */
/* Set proper schema search path so regproc references list correctly */
selectSourceSchema
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
);
selectSourceSchema
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
);
appendPQExpBuffer
(
query
,
"SELECT enumlabel FROM pg_catalog.pg_enum "
appendPQExpBuffer
(
query
,
"SELECT enumlabel FROM pg_catalog.pg_enum "
"WHERE enumtypid = '%u'"
"WHERE enumtypid = '%u'"
"ORDER BY oid"
,
"ORDER BY oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
res
=
PQexec
(
g_conn
,
query
->
data
);
res
=
PQexec
(
g_conn
,
query
->
data
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
...
@@ -6415,7 +6415,7 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
...
@@ -6415,7 +6415,7 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
/* should be at least 1 value */
/* should be at least 1 value */
if
(
num
==
0
)
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
"
,
t
y
info
->
dobj
.
catId
.
oid
);
exit_nicely
();
exit_nicely
();
}
}
...
@@ -6425,11 +6425,11 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
...
@@ -6425,11 +6425,11 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
* functions are generic and do not get dropped.
* functions are generic and do not get dropped.
*/
*/
appendPQExpBuffer
(
delq
,
"DROP TYPE %s."
,
appendPQExpBuffer
(
delq
,
"DROP TYPE %s."
,
fmtId
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
));
appendPQExpBuffer
(
delq
,
"%s;
\n
"
,
appendPQExpBuffer
(
delq
,
"%s;
\n
"
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
"CREATE TYPE %s AS ENUM (
\n
"
,
appendPQExpBuffer
(
q
,
"CREATE TYPE %s AS ENUM (
\n
"
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
for
(
i
=
0
;
i
<
num
;
i
++
)
for
(
i
=
0
;
i
<
num
;
i
++
)
{
{
label
=
PQgetvalue
(
res
,
i
,
0
);
label
=
PQgetvalue
(
res
,
i
,
0
);
...
@@ -6440,23 +6440,23 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
...
@@ -6440,23 +6440,23 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
}
}
appendPQExpBuffer
(
q
,
"
\n
);
\n
"
);
appendPQExpBuffer
(
q
,
"
\n
);
\n
"
);
ArchiveEntry
(
fout
,
t
info
->
dobj
.
catId
,
t
info
->
dobj
.
dumpId
,
ArchiveEntry
(
fout
,
t
yinfo
->
dobj
.
catId
,
ty
info
->
dobj
.
dumpId
,
tinfo
->
dobj
.
name
,
t
y
info
->
dobj
.
name
,
tinfo
->
dobj
.
namespace
->
dobj
.
name
,
t
y
info
->
dobj
.
namespace
->
dobj
.
name
,
NULL
,
NULL
,
tinfo
->
rolname
,
false
,
t
y
info
->
rolname
,
false
,
"TYPE"
,
SECTION_PRE_DATA
,
"TYPE"
,
SECTION_PRE_DATA
,
q
->
data
,
delq
->
data
,
NULL
,
q
->
data
,
delq
->
data
,
NULL
,
t
info
->
dobj
.
dependencies
,
t
info
->
dobj
.
nDeps
,
t
yinfo
->
dobj
.
dependencies
,
ty
info
->
dobj
.
nDeps
,
NULL
,
NULL
);
NULL
,
NULL
);
/* Dump Type Comments */
/* Dump Type Comments */
resetPQExpBuffer
(
q
);
resetPQExpBuffer
(
q
);
appendPQExpBuffer
(
q
,
"TYPE %s"
,
fmtId
(
tinfo
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
"TYPE %s"
,
fmtId
(
t
y
info
->
dobj
.
name
));
dumpComment
(
fout
,
q
->
data
,
dumpComment
(
fout
,
q
->
data
,
t
info
->
dobj
.
namespace
->
dobj
.
name
,
t
info
->
rolname
,
t
yinfo
->
dobj
.
namespace
->
dobj
.
name
,
ty
info
->
rolname
,
t
info
->
dobj
.
catId
,
0
,
t
info
->
dobj
.
dumpId
);
t
yinfo
->
dobj
.
catId
,
0
,
ty
info
->
dobj
.
dumpId
);
PQclear
(
res
);
PQclear
(
res
);
destroyPQExpBuffer
(
q
);
destroyPQExpBuffer
(
q
);
...
@@ -6469,7 +6469,7 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
...
@@ -6469,7 +6469,7 @@ dumpEnumType(Archive *fout, TypeInfo *tinfo)
* writes out to fout the queries to recreate a user-defined base type
* writes out to fout the queries to recreate a user-defined base type
*/
*/
static
void
static
void
dumpBaseType
(
Archive
*
fout
,
TypeInfo
*
tinfo
)
dumpBaseType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
)
{
{
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
...
@@ -6501,7 +6501,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6501,7 +6501,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
bool
typdefault_is_literal
=
false
;
bool
typdefault_is_literal
=
false
;
/* Set proper schema search path so regproc references list correctly */
/* Set proper schema search path so regproc references list correctly */
selectSourceSchema
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
);
selectSourceSchema
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
);
/* Fetch type-specific details */
/* Fetch type-specific details */
if
(
fout
->
remoteVersion
>=
80400
)
if
(
fout
->
remoteVersion
>=
80400
)
...
@@ -6521,7 +6521,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6521,7 +6521,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "
"pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid"
,
"WHERE oid = '%u'::pg_catalog.oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
if
(
fout
->
remoteVersion
>=
80300
)
else
if
(
fout
->
remoteVersion
>=
80300
)
{
{
...
@@ -6541,7 +6541,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6541,7 +6541,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid"
,
"WHERE oid = '%u'::pg_catalog.oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
if
(
fout
->
remoteVersion
>=
80000
)
else
if
(
fout
->
remoteVersion
>=
80000
)
{
{
...
@@ -6560,7 +6560,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6560,7 +6560,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid"
,
"WHERE oid = '%u'::pg_catalog.oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
if
(
fout
->
remoteVersion
>=
70400
)
else
if
(
fout
->
remoteVersion
>=
70400
)
{
{
...
@@ -6579,7 +6579,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6579,7 +6579,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid"
,
"WHERE oid = '%u'::pg_catalog.oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
if
(
fout
->
remoteVersion
>=
70300
)
else
if
(
fout
->
remoteVersion
>=
70300
)
{
{
...
@@ -6598,7 +6598,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6598,7 +6598,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid"
,
"WHERE oid = '%u'::pg_catalog.oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
if
(
fout
->
remoteVersion
>=
70200
)
else
if
(
fout
->
remoteVersion
>=
70200
)
{
{
...
@@ -6621,7 +6621,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6621,7 +6621,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"NULL AS typdefaultbin, typdefault "
"NULL AS typdefaultbin, typdefault "
"FROM pg_type "
"FROM pg_type "
"WHERE oid = '%u'::oid"
,
"WHERE oid = '%u'::oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
if
(
fout
->
remoteVersion
>=
70100
)
else
if
(
fout
->
remoteVersion
>=
70100
)
{
{
...
@@ -6644,7 +6644,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6644,7 +6644,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"NULL AS typdefaultbin, NULL AS typdefault "
"NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type "
"FROM pg_type "
"WHERE oid = '%u'::oid"
,
"WHERE oid = '%u'::oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
else
else
{
{
...
@@ -6664,7 +6664,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6664,7 +6664,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
"NULL AS typdefaultbin, NULL AS typdefault "
"NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type "
"FROM pg_type "
"WHERE oid = '%u'::oid"
,
"WHERE oid = '%u'::oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
}
}
res
=
PQexec
(
g_conn
,
query
->
data
);
res
=
PQexec
(
g_conn
,
query
->
data
);
...
@@ -6719,14 +6719,14 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6719,14 +6719,14 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
* other way.
* other way.
*/
*/
appendPQExpBuffer
(
delq
,
"DROP TYPE %s."
,
appendPQExpBuffer
(
delq
,
"DROP TYPE %s."
,
fmtId
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
));
appendPQExpBuffer
(
delq
,
"%s CASCADE;
\n
"
,
appendPQExpBuffer
(
delq
,
"%s CASCADE;
\n
"
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
appendPQExpBuffer
(
q
,
"CREATE TYPE %s (
\n
"
"CREATE TYPE %s (
\n
"
" INTERNALLENGTH = %s"
,
" INTERNALLENGTH = %s"
,
fmtId
(
tinfo
->
dobj
.
name
),
fmtId
(
t
y
info
->
dobj
.
name
),
(
strcmp
(
typlen
,
"-1"
)
==
0
)
?
"variable"
:
typlen
);
(
strcmp
(
typlen
,
"-1"
)
==
0
)
?
"variable"
:
typlen
);
if
(
fout
->
remoteVersion
>=
70300
)
if
(
fout
->
remoteVersion
>=
70300
)
...
@@ -6763,13 +6763,13 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6763,13 +6763,13 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
appendPQExpBufferStr
(
q
,
typdefault
);
appendPQExpBufferStr
(
q
,
typdefault
);
}
}
if
(
OidIsValid
(
tinfo
->
typelem
))
if
(
OidIsValid
(
t
y
info
->
typelem
))
{
{
char
*
elemType
;
char
*
elemType
;
/* reselect schema in case changed by function dump */
/* reselect schema in case changed by function dump */
selectSourceSchema
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
);
selectSourceSchema
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
);
elemType
=
getFormattedTypeName
(
tinfo
->
typelem
,
zeroAsOpaque
);
elemType
=
getFormattedTypeName
(
t
y
info
->
typelem
,
zeroAsOpaque
);
appendPQExpBuffer
(
q
,
",
\n
ELEMENT = %s"
,
elemType
);
appendPQExpBuffer
(
q
,
",
\n
ELEMENT = %s"
,
elemType
);
free
(
elemType
);
free
(
elemType
);
}
}
...
@@ -6812,23 +6812,23 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6812,23 +6812,23 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer
(
q
,
"
\n
);
\n
"
);
appendPQExpBuffer
(
q
,
"
\n
);
\n
"
);
ArchiveEntry
(
fout
,
t
info
->
dobj
.
catId
,
t
info
->
dobj
.
dumpId
,
ArchiveEntry
(
fout
,
t
yinfo
->
dobj
.
catId
,
ty
info
->
dobj
.
dumpId
,
tinfo
->
dobj
.
name
,
t
y
info
->
dobj
.
name
,
tinfo
->
dobj
.
namespace
->
dobj
.
name
,
t
y
info
->
dobj
.
namespace
->
dobj
.
name
,
NULL
,
NULL
,
tinfo
->
rolname
,
false
,
t
y
info
->
rolname
,
false
,
"TYPE"
,
SECTION_PRE_DATA
,
"TYPE"
,
SECTION_PRE_DATA
,
q
->
data
,
delq
->
data
,
NULL
,
q
->
data
,
delq
->
data
,
NULL
,
t
info
->
dobj
.
dependencies
,
t
info
->
dobj
.
nDeps
,
t
yinfo
->
dobj
.
dependencies
,
ty
info
->
dobj
.
nDeps
,
NULL
,
NULL
);
NULL
,
NULL
);
/* Dump Type Comments */
/* Dump Type Comments */
resetPQExpBuffer
(
q
);
resetPQExpBuffer
(
q
);
appendPQExpBuffer
(
q
,
"TYPE %s"
,
fmtId
(
tinfo
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
"TYPE %s"
,
fmtId
(
t
y
info
->
dobj
.
name
));
dumpComment
(
fout
,
q
->
data
,
dumpComment
(
fout
,
q
->
data
,
t
info
->
dobj
.
namespace
->
dobj
.
name
,
t
info
->
rolname
,
t
yinfo
->
dobj
.
namespace
->
dobj
.
name
,
ty
info
->
rolname
,
t
info
->
dobj
.
catId
,
0
,
t
info
->
dobj
.
dumpId
);
t
yinfo
->
dobj
.
catId
,
0
,
ty
info
->
dobj
.
dumpId
);
PQclear
(
res
);
PQclear
(
res
);
destroyPQExpBuffer
(
q
);
destroyPQExpBuffer
(
q
);
...
@@ -6841,7 +6841,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
...
@@ -6841,7 +6841,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
* writes out to fout the queries to recreate a user-defined domain
* writes out to fout the queries to recreate a user-defined domain
*/
*/
static
void
static
void
dumpDomain
(
Archive
*
fout
,
TypeInfo
*
tinfo
)
dumpDomain
(
Archive
*
fout
,
TypeInfo
*
t
y
info
)
{
{
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
...
@@ -6855,7 +6855,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
...
@@ -6855,7 +6855,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
bool
typdefault_is_literal
=
false
;
bool
typdefault_is_literal
=
false
;
/* Set proper schema search path so type references list correctly */
/* Set proper schema search path so type references list correctly */
selectSourceSchema
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
);
selectSourceSchema
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
);
/* Fetch domain specific details */
/* Fetch domain specific details */
/* We assume here that remoteVersion must be at least 70300 */
/* We assume here that remoteVersion must be at least 70300 */
...
@@ -6864,7 +6864,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
...
@@ -6864,7 +6864,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type "
"FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid"
,
"WHERE oid = '%u'::pg_catalog.oid"
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
res
=
PQexec
(
g_conn
,
query
->
data
);
res
=
PQexec
(
g_conn
,
query
->
data
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
...
@@ -6894,7 +6894,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
...
@@ -6894,7 +6894,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
appendPQExpBuffer
(
q
,
appendPQExpBuffer
(
q
,
"CREATE DOMAIN %s AS %s"
,
"CREATE DOMAIN %s AS %s"
,
fmtId
(
tinfo
->
dobj
.
name
),
fmtId
(
t
y
info
->
dobj
.
name
),
typdefn
);
typdefn
);
if
(
typnotnull
[
0
]
==
't'
)
if
(
typnotnull
[
0
]
==
't'
)
...
@@ -6914,9 +6914,9 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
...
@@ -6914,9 +6914,9 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
/*
/*
* Add any CHECK constraints for the domain
* Add any CHECK constraints for the domain
*/
*/
for
(
i
=
0
;
i
<
tinfo
->
nDomChecks
;
i
++
)
for
(
i
=
0
;
i
<
t
y
info
->
nDomChecks
;
i
++
)
{
{
ConstraintInfo
*
domcheck
=
&
(
tinfo
->
domChecks
[
i
]);
ConstraintInfo
*
domcheck
=
&
(
t
y
info
->
domChecks
[
i
]);
if
(
!
domcheck
->
separate
)
if
(
!
domcheck
->
separate
)
appendPQExpBuffer
(
q
,
"
\n\t
CONSTRAINT %s %s"
,
appendPQExpBuffer
(
q
,
"
\n\t
CONSTRAINT %s %s"
,
...
@@ -6929,27 +6929,27 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
...
@@ -6929,27 +6929,27 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
* DROP must be fully qualified in case same name appears in pg_catalog
* DROP must be fully qualified in case same name appears in pg_catalog
*/
*/
appendPQExpBuffer
(
delq
,
"DROP DOMAIN %s."
,
appendPQExpBuffer
(
delq
,
"DROP DOMAIN %s."
,
fmtId
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
));
appendPQExpBuffer
(
delq
,
"%s;
\n
"
,
appendPQExpBuffer
(
delq
,
"%s;
\n
"
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
ArchiveEntry
(
fout
,
t
info
->
dobj
.
catId
,
t
info
->
dobj
.
dumpId
,
ArchiveEntry
(
fout
,
t
yinfo
->
dobj
.
catId
,
ty
info
->
dobj
.
dumpId
,
tinfo
->
dobj
.
name
,
t
y
info
->
dobj
.
name
,
tinfo
->
dobj
.
namespace
->
dobj
.
name
,
t
y
info
->
dobj
.
namespace
->
dobj
.
name
,
NULL
,
NULL
,
tinfo
->
rolname
,
false
,
t
y
info
->
rolname
,
false
,
"DOMAIN"
,
SECTION_PRE_DATA
,
"DOMAIN"
,
SECTION_PRE_DATA
,
q
->
data
,
delq
->
data
,
NULL
,
q
->
data
,
delq
->
data
,
NULL
,
t
info
->
dobj
.
dependencies
,
t
info
->
dobj
.
nDeps
,
t
yinfo
->
dobj
.
dependencies
,
ty
info
->
dobj
.
nDeps
,
NULL
,
NULL
);
NULL
,
NULL
);
/* Dump Domain Comments */
/* Dump Domain Comments */
resetPQExpBuffer
(
q
);
resetPQExpBuffer
(
q
);
appendPQExpBuffer
(
q
,
"DOMAIN %s"
,
fmtId
(
tinfo
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
"DOMAIN %s"
,
fmtId
(
t
y
info
->
dobj
.
name
));
dumpComment
(
fout
,
q
->
data
,
dumpComment
(
fout
,
q
->
data
,
t
info
->
dobj
.
namespace
->
dobj
.
name
,
t
info
->
rolname
,
t
yinfo
->
dobj
.
namespace
->
dobj
.
name
,
ty
info
->
rolname
,
t
info
->
dobj
.
catId
,
0
,
t
info
->
dobj
.
dumpId
);
t
yinfo
->
dobj
.
catId
,
0
,
ty
info
->
dobj
.
dumpId
);
destroyPQExpBuffer
(
q
);
destroyPQExpBuffer
(
q
);
destroyPQExpBuffer
(
delq
);
destroyPQExpBuffer
(
delq
);
...
@@ -6962,7 +6962,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
...
@@ -6962,7 +6962,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
* composite type
* composite type
*/
*/
static
void
static
void
dumpCompositeType
(
Archive
*
fout
,
TypeInfo
*
tinfo
)
dumpCompositeType
(
Archive
*
fout
,
TypeInfo
*
t
y
info
)
{
{
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
q
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
PQExpBuffer
delq
=
createPQExpBuffer
();
...
@@ -6974,7 +6974,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
...
@@ -6974,7 +6974,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
int
i
;
int
i
;
/* Set proper schema search path so type references list correctly */
/* Set proper schema search path so type references list correctly */
selectSourceSchema
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
);
selectSourceSchema
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
);
/* Fetch type specific details */
/* Fetch type specific details */
/* We assume here that remoteVersion must be at least 70300 */
/* We assume here that remoteVersion must be at least 70300 */
...
@@ -6986,7 +6986,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
...
@@ -6986,7 +6986,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
"AND a.attrelid = t.typrelid "
"AND a.attrelid = t.typrelid "
"AND NOT a.attisdropped "
"AND NOT a.attisdropped "
"ORDER BY a.attnum "
,
"ORDER BY a.attnum "
,
tinfo
->
dobj
.
catId
.
oid
);
t
y
info
->
dobj
.
catId
.
oid
);
res
=
PQexec
(
g_conn
,
query
->
data
);
res
=
PQexec
(
g_conn
,
query
->
data
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
check_sql_result
(
res
,
g_conn
,
query
->
data
,
PGRES_TUPLES_OK
);
...
@@ -7003,7 +7003,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
...
@@ -7003,7 +7003,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
i_atttypdefn
=
PQfnumber
(
res
,
"atttypdefn"
);
i_atttypdefn
=
PQfnumber
(
res
,
"atttypdefn"
);
appendPQExpBuffer
(
q
,
"CREATE TYPE %s AS ("
,
appendPQExpBuffer
(
q
,
"CREATE TYPE %s AS ("
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
for
(
i
=
0
;
i
<
ntups
;
i
++
)
for
(
i
=
0
;
i
<
ntups
;
i
++
)
{
{
...
@@ -7023,28 +7023,28 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
...
@@ -7023,28 +7023,28 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
* DROP must be fully qualified in case same name appears in pg_catalog
* DROP must be fully qualified in case same name appears in pg_catalog
*/
*/
appendPQExpBuffer
(
delq
,
"DROP TYPE %s."
,
appendPQExpBuffer
(
delq
,
"DROP TYPE %s."
,
fmtId
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
));
appendPQExpBuffer
(
delq
,
"%s;
\n
"
,
appendPQExpBuffer
(
delq
,
"%s;
\n
"
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
ArchiveEntry
(
fout
,
t
info
->
dobj
.
catId
,
t
info
->
dobj
.
dumpId
,
ArchiveEntry
(
fout
,
t
yinfo
->
dobj
.
catId
,
ty
info
->
dobj
.
dumpId
,
tinfo
->
dobj
.
name
,
t
y
info
->
dobj
.
name
,
tinfo
->
dobj
.
namespace
->
dobj
.
name
,
t
y
info
->
dobj
.
namespace
->
dobj
.
name
,
NULL
,
NULL
,
tinfo
->
rolname
,
false
,
t
y
info
->
rolname
,
false
,
"TYPE"
,
SECTION_PRE_DATA
,
"TYPE"
,
SECTION_PRE_DATA
,
q
->
data
,
delq
->
data
,
NULL
,
q
->
data
,
delq
->
data
,
NULL
,
t
info
->
dobj
.
dependencies
,
t
info
->
dobj
.
nDeps
,
t
yinfo
->
dobj
.
dependencies
,
ty
info
->
dobj
.
nDeps
,
NULL
,
NULL
);
NULL
,
NULL
);
/* Dump Type Comments */
/* Dump Type Comments */
resetPQExpBuffer
(
q
);
resetPQExpBuffer
(
q
);
appendPQExpBuffer
(
q
,
"TYPE %s"
,
fmtId
(
tinfo
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
"TYPE %s"
,
fmtId
(
t
y
info
->
dobj
.
name
));
dumpComment
(
fout
,
q
->
data
,
dumpComment
(
fout
,
q
->
data
,
t
info
->
dobj
.
namespace
->
dobj
.
name
,
t
info
->
rolname
,
t
yinfo
->
dobj
.
namespace
->
dobj
.
name
,
ty
info
->
rolname
,
t
info
->
dobj
.
catId
,
0
,
t
info
->
dobj
.
dumpId
);
t
yinfo
->
dobj
.
catId
,
0
,
ty
info
->
dobj
.
dumpId
);
PQclear
(
res
);
PQclear
(
res
);
destroyPQExpBuffer
(
q
);
destroyPQExpBuffer
(
q
);
...
@@ -7052,7 +7052,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
...
@@ -7052,7 +7052,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
destroyPQExpBuffer
(
query
);
destroyPQExpBuffer
(
query
);
/* Dump any per-column comments */
/* Dump any per-column comments */
dumpCompositeTypeColComments
(
fout
,
tinfo
);
dumpCompositeTypeColComments
(
fout
,
t
y
info
);
}
}
/*
/*
...
@@ -7061,7 +7061,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
...
@@ -7061,7 +7061,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo)
* a user-defined stand-alone composite type
* a user-defined stand-alone composite type
*/
*/
static
void
static
void
dumpCompositeTypeColComments
(
Archive
*
fout
,
TypeInfo
*
tinfo
)
dumpCompositeTypeColComments
(
Archive
*
fout
,
TypeInfo
*
t
y
info
)
{
{
CommentItem
*
comments
;
CommentItem
*
comments
;
int
ncomments
;
int
ncomments
;
...
@@ -7083,7 +7083,7 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
...
@@ -7083,7 +7083,7 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
"WHERE c.oid = '%u' AND c.oid = a.attrelid "
"WHERE c.oid = '%u' AND c.oid = a.attrelid "
" AND NOT a.attisdropped "
" AND NOT a.attisdropped "
"ORDER BY a.attnum "
,
"ORDER BY a.attnum "
,
tinfo
->
typrelid
);
t
y
info
->
typrelid
);
/* Fetch column attnames */
/* Fetch column attnames */
res
=
PQexec
(
g_conn
,
query
->
data
);
res
=
PQexec
(
g_conn
,
query
->
data
);
...
@@ -7102,7 +7102,7 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
...
@@ -7102,7 +7102,7 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
/* Search for comments associated with type's pg_class OID */
/* Search for comments associated with type's pg_class OID */
ncomments
=
findComments
(
fout
,
ncomments
=
findComments
(
fout
,
pgClassOid
,
pgClassOid
,
tinfo
->
typrelid
,
t
y
info
->
typrelid
,
&
comments
);
&
comments
);
/* If no comments exist, we're done */
/* If no comments exist, we're done */
...
@@ -7137,7 +7137,7 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
...
@@ -7137,7 +7137,7 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
resetPQExpBuffer
(
target
);
resetPQExpBuffer
(
target
);
appendPQExpBuffer
(
target
,
"COLUMN %s."
,
appendPQExpBuffer
(
target
,
"COLUMN %s."
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
appendPQExpBuffer
(
target
,
"%s"
,
appendPQExpBuffer
(
target
,
"%s"
,
fmtId
(
attname
));
fmtId
(
attname
));
...
@@ -7148,11 +7148,11 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
...
@@ -7148,11 +7148,11 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tinfo)
ArchiveEntry
(
fout
,
nilCatalogId
,
createDumpId
(),
ArchiveEntry
(
fout
,
nilCatalogId
,
createDumpId
(),
target
->
data
,
target
->
data
,
tinfo
->
dobj
.
namespace
->
dobj
.
name
,
t
y
info
->
dobj
.
namespace
->
dobj
.
name
,
NULL
,
tinfo
->
rolname
,
NULL
,
t
y
info
->
rolname
,
false
,
"COMMENT"
,
SECTION_NONE
,
false
,
"COMMENT"
,
SECTION_NONE
,
query
->
data
,
""
,
NULL
,
query
->
data
,
""
,
NULL
,
&
(
tinfo
->
dobj
.
dumpId
),
1
,
&
(
t
y
info
->
dobj
.
dumpId
),
1
,
NULL
,
NULL
);
NULL
,
NULL
);
}
}
...
@@ -10972,13 +10972,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
...
@@ -10972,13 +10972,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
else
if
(
coninfo
->
contype
==
'c'
&&
tbinfo
==
NULL
)
else
if
(
coninfo
->
contype
==
'c'
&&
tbinfo
==
NULL
)
{
{
/* CHECK constraint on a domain */
/* CHECK constraint on a domain */
TypeInfo
*
tinfo
=
coninfo
->
condomain
;
TypeInfo
*
t
y
info
=
coninfo
->
condomain
;
/* Ignore if not to be dumped separately */
/* Ignore if not to be dumped separately */
if
(
coninfo
->
separate
)
if
(
coninfo
->
separate
)
{
{
appendPQExpBuffer
(
q
,
"ALTER DOMAIN %s
\n
"
,
appendPQExpBuffer
(
q
,
"ALTER DOMAIN %s
\n
"
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
appendPQExpBuffer
(
q
,
" ADD CONSTRAINT %s %s;
\n
"
,
appendPQExpBuffer
(
q
,
" ADD CONSTRAINT %s %s;
\n
"
,
fmtId
(
coninfo
->
dobj
.
name
),
fmtId
(
coninfo
->
dobj
.
name
),
coninfo
->
condef
);
coninfo
->
condef
);
...
@@ -10988,17 +10988,17 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
...
@@ -10988,17 +10988,17 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
* pg_catalog
* pg_catalog
*/
*/
appendPQExpBuffer
(
delq
,
"ALTER DOMAIN %s."
,
appendPQExpBuffer
(
delq
,
"ALTER DOMAIN %s."
,
fmtId
(
tinfo
->
dobj
.
namespace
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
namespace
->
dobj
.
name
));
appendPQExpBuffer
(
delq
,
"%s "
,
appendPQExpBuffer
(
delq
,
"%s "
,
fmtId
(
tinfo
->
dobj
.
name
));
fmtId
(
t
y
info
->
dobj
.
name
));
appendPQExpBuffer
(
delq
,
"DROP CONSTRAINT %s;
\n
"
,
appendPQExpBuffer
(
delq
,
"DROP CONSTRAINT %s;
\n
"
,
fmtId
(
coninfo
->
dobj
.
name
));
fmtId
(
coninfo
->
dobj
.
name
));
ArchiveEntry
(
fout
,
coninfo
->
dobj
.
catId
,
coninfo
->
dobj
.
dumpId
,
ArchiveEntry
(
fout
,
coninfo
->
dobj
.
catId
,
coninfo
->
dobj
.
dumpId
,
coninfo
->
dobj
.
name
,
coninfo
->
dobj
.
name
,
tinfo
->
dobj
.
namespace
->
dobj
.
name
,
t
y
info
->
dobj
.
namespace
->
dobj
.
name
,
NULL
,
NULL
,
tinfo
->
rolname
,
false
,
t
y
info
->
rolname
,
false
,
"CHECK CONSTRAINT"
,
SECTION_POST_DATA
,
"CHECK CONSTRAINT"
,
SECTION_POST_DATA
,
q
->
data
,
delq
->
data
,
NULL
,
q
->
data
,
delq
->
data
,
NULL
,
coninfo
->
dobj
.
dependencies
,
coninfo
->
dobj
.
nDeps
,
coninfo
->
dobj
.
dependencies
,
coninfo
->
dobj
.
nDeps
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment