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
dc19aaa1
Commit
dc19aaa1
authored
Oct 16, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give a more user-friendly error message in case where a table is created
in a schema whose default tablespace has been dropped.
parent
2a63c160
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+41
-1
No files found.
src/backend/commands/tablecmds.c
View file @
dc19aaa1
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.13
4 2004/10/12 21:54:36 petere
Exp $
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.13
5 2004/10/16 21:16:36 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -168,6 +168,7 @@ static void StoreCatalogInheritance(Oid relationId, List *supers);
static
int
findAttrByName
(
const
char
*
attributeName
,
List
*
schema
);
static
void
setRelhassubclassInRelation
(
Oid
relationId
,
bool
relhassubclass
);
static
bool
needs_toast_table
(
Relation
rel
);
static
void
check_tablespace_exists
(
Oid
tablespaceId
,
Oid
namespaceId
);
static
int
transformColumnNameList
(
Oid
relId
,
List
*
colList
,
int16
*
attnums
,
Oid
*
atttypids
);
static
int
transformFkeyGetPrimaryKey
(
Relation
pkrel
,
Oid
*
indexOid
,
...
...
@@ -337,6 +338,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
{
tablespaceId
=
get_namespace_tablespace
(
namespaceId
);
/* note no permission check on tablespace in this case */
/* check to see that schema's tablespace still exists */
if
(
OidIsValid
(
tablespaceId
))
check_tablespace_exists
(
tablespaceId
,
namespaceId
);
}
/*
...
...
@@ -5865,6 +5869,42 @@ needs_toast_table(Relation rel)
return
(
tuple_length
>
TOAST_TUPLE_THRESHOLD
);
}
/*
* Verify that a schema's tablespace still exists
*
* We need this because DROP TABLESPACE cannot check whether the target
* tablespace is the default tablespace for any schemas. (It could check
* in the current database, but that doesn't seem very helpful.) Subsequent
* attempts to create tables in that tablespace will fail. This code just
* exists to ensure that we give a helpful error message.
*/
static
void
check_tablespace_exists
(
Oid
tablespaceId
,
Oid
namespaceId
)
{
Relation
pg_tablespace
;
ScanKeyData
entry
[
1
];
HeapScanDesc
scan
;
HeapTuple
tuple
;
/* There's no syscache for pg_tablespace, so must look the hard way */
pg_tablespace
=
heap_openr
(
TableSpaceRelationName
,
AccessShareLock
);
ScanKeyInit
(
&
entry
[
0
],
ObjectIdAttributeNumber
,
BTEqualStrategyNumber
,
F_OIDEQ
,
ObjectIdGetDatum
(
tablespaceId
));
scan
=
heap_beginscan
(
pg_tablespace
,
SnapshotNow
,
1
,
entry
);
tuple
=
heap_getnext
(
scan
,
ForwardScanDirection
);
if
(
!
HeapTupleIsValid
(
tuple
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"tablespace with OID %u does not exist"
,
tablespaceId
),
errdetail
(
"The default tablespace for schema
\"
%s
\"
has been dropped."
,
get_namespace_name
(
namespaceId
))));
heap_endscan
(
scan
);
heap_close
(
pg_tablespace
,
AccessShareLock
);
}
/*
* This code supports
...
...
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