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
3faf224a
Commit
3faf224a
authored
Apr 22, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix incorrect Assert; install a more trustworthy check on whether
ALTER COLUMN SET STORAGE should be allowed.
parent
fccda9eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+20
-14
No files found.
src/backend/commands/tablecmds.c
View file @
3faf224a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.
5 2002/04/19 23:13:54
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.
6 2002/04/22 21:46:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -771,10 +771,10 @@ AlterTableAlterColumnFlags(Oid myrelid,
{
Relation
rel
;
int
newtarget
=
1
;
char
newstorage
=
'x'
;
char
*
storagemode
;
char
newstorage
=
'p'
;
Relation
attrelation
;
HeapTuple
tuple
;
Form_pg_attribute
attrtuple
;
rel
=
heap_open
(
myrelid
,
AccessExclusiveLock
);
...
...
@@ -813,9 +813,11 @@ AlterTableAlterColumnFlags(Oid myrelid,
else
if
(
*
flagType
==
'M'
)
{
/* STORAGE */
Assert
(
IsA
(
flagValue
,
Value
))
;
char
*
storagemode
;
Assert
(
IsA
(
flagValue
,
String
));
storagemode
=
strVal
(
flagValue
);
if
(
strcasecmp
(
storagemode
,
"plain"
)
==
0
)
newstorage
=
'p'
;
else
if
(
strcasecmp
(
storagemode
,
"external"
)
==
0
)
...
...
@@ -872,26 +874,30 @@ AlterTableAlterColumnFlags(Oid myrelid,
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"ALTER TABLE: relation
\"
%s
\"
has no column
\"
%s
\"
"
,
RelationGetRelationName
(
rel
),
colName
);
attrtuple
=
(
Form_pg_attribute
)
GETSTRUCT
(
tuple
);
if
(
((
Form_pg_attribute
)
GETSTRUCT
(
tuple
))
->
attnum
<
0
)
if
(
attrtuple
->
attnum
<
0
)
elog
(
ERROR
,
"ALTER TABLE: cannot change system attribute
\"
%s
\"
"
,
colName
);
/*
* Now change the appropriate field
*/
if
(
*
flagType
==
'S'
)
((
Form_pg_attribute
)
GETSTRUCT
(
tuple
))
->
attstattarget
=
newtarget
;
else
attrtuple
->
attstattarget
=
newtarget
;
else
if
(
*
flagType
==
'M'
)
{
if
((
newstorage
==
'p'
)
||
(((
Form_pg_attribute
)
GETSTRUCT
(
tuple
))
->
attlen
==
-
1
))
((
Form_pg_attribute
)
GETSTRUCT
(
tuple
))
->
attstorage
=
newstorage
;
/*
* safety check: do not allow toasted storage modes unless column
* datatype is TOAST-aware. We assume the datatype's typstorage
* will be 'p' if and only if it ain't TOAST-aware.
*/
if
(
newstorage
==
'p'
||
get_typstorage
(
attrtuple
->
atttypid
)
!=
'p'
)
attrtuple
->
attstorage
=
newstorage
;
else
{
elog
(
ERROR
,
"ALTER TABLE: Fixed-length columns can only have storage
\"
plain
\"
"
);
}
elog
(
ERROR
,
"ALTER TABLE: Column datatype %s can only have storage
\"
plain
\"
"
,
format_type_be
(
attrtuple
->
atttypid
));
}
simple_heap_update
(
attrelation
,
&
tuple
->
t_self
,
tuple
);
/* keep system catalog indices current */
...
...
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