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
fa5400c0
Commit
fa5400c0
authored
Jan 22, 2000
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added ALTER TABLE DROP COLUMN, early version
parent
3f51bdaf
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
286 additions
and
82 deletions
+286
-82
src/backend/access/heap/heapam.c
src/backend/access/heap/heapam.c
+2
-2
src/backend/catalog/catalog.c
src/backend/catalog/catalog.c
+2
-2
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+3
-3
src/backend/catalog/pg_type.c
src/backend/catalog/pg_type.c
+2
-2
src/backend/commands/command.c
src/backend/commands/command.c
+215
-12
src/backend/commands/rename.c
src/backend/commands/rename.c
+2
-2
src/backend/parser/gram.y
src/backend/parser/gram.y
+3
-3
src/backend/utils/adt/name.c
src/backend/utils/adt/name.c
+12
-12
src/backend/utils/cache/relcache.c
src/backend/utils/cache/relcache.c
+9
-9
src/backend/utils/cache/temprel.c
src/backend/utils/cache/temprel.c
+5
-5
src/bin/psql/command.c
src/bin/psql/command.c
+2
-1
src/include/access/heapam.h
src/include/access/heapam.h
+2
-2
src/include/catalog/heap.h
src/include/catalog/heap.h
+3
-3
src/include/catalog/pg_type.h
src/include/catalog/pg_type.h
+2
-2
src/include/commands/rename.h
src/include/commands/rename.h
+3
-3
src/include/utils/builtins.h
src/include/utils/builtins.h
+11
-11
src/include/utils/rel.h
src/include/utils/rel.h
+2
-2
src/include/utils/relcache.h
src/include/utils/relcache.h
+2
-2
src/include/utils/temprel.h
src/include/utils/temprel.h
+4
-4
No files found.
src/backend/access/heap/heapam.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.6
3 2000/01/10 06:30:50 inou
e Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.6
4 2000/01/22 14:20:43 peter
e Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -562,7 +562,7 @@ heap_open(Oid relationId, LOCKMODE lockmode)
* ----------------
*/
Relation
heap_openr
(
char
*
relationName
,
LOCKMODE
lockmode
)
heap_openr
(
c
onst
c
har
*
relationName
,
LOCKMODE
lockmode
)
{
Relation
r
;
...
...
src/backend/catalog/catalog.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.2
8 2000/01/16 20:04:5
4 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.2
9 2000/01/22 14:20:4
4 petere Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -38,7 +38,7 @@ relpath(const char *relname)
snprintf
(
path
,
bufsize
,
"%s/%s"
,
DataDir
,
relname
);
return
path
;
}
return
relname
;
return
pstrdup
(
relname
)
;
}
/*
...
...
src/backend/catalog/heap.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.11
7 2000/01/17 23:57:43 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.11
8 2000/01/22 14:20:44 petere
Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -480,7 +480,7 @@ CheckAttributeNames(TupleDesc tupdesc)
* --------------------------------
*/
Oid
RelnameFindRelid
(
char
*
relname
)
RelnameFindRelid
(
c
onst
c
har
*
relname
)
{
HeapTuple
tuple
;
Oid
relid
;
...
...
@@ -1441,7 +1441,7 @@ DeleteTypeTuple(Relation rel)
* --------------------------------
*/
void
heap_drop_with_catalog
(
char
*
relname
)
heap_drop_with_catalog
(
c
onst
c
har
*
relname
)
{
Relation
rel
;
Oid
rid
;
...
...
src/backend/catalog/pg_type.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.4
7 2000/01/17 23:57:43 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.4
8 2000/01/22 14:20:44 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -525,7 +525,7 @@ TypeCreate(char *typeName,
* ----------------------------------------------------------------
*/
void
TypeRename
(
c
har
*
oldTypeName
,
char
*
newTypeName
)
TypeRename
(
c
onst
char
*
oldTypeName
,
const
char
*
newTypeName
)
{
Relation
pg_type_desc
;
Relation
idescs
[
Num_pg_type_indices
];
...
...
src/backend/commands/command.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.6
3 2000/01/16 20:04:5
5 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.6
4 2000/01/22 14:20:4
5 petere Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
...
...
@@ -30,6 +30,7 @@
#include "catalog/pg_attrdef.h"
#include "catalog/pg_type.h"
#include "commands/command.h"
#include "commands/rename.h"
#include "executor/execdefs.h"
#include "executor/executor.h"
#include "catalog/heap.h"
...
...
@@ -299,7 +300,7 @@ AlterTableAddColumn(const char *relationName,
Relation
idescs
[
Num_pg_attr_indices
];
Relation
ridescs
[
Num_pg_class_indices
];
bool
hasindex
;
List
*
rawDefaults
=
NIL
;
//
List *rawDefaults = NIL;
/*
* permissions checking. this would normally be done in utility.c,
...
...
@@ -319,7 +320,7 @@ AlterTableAddColumn(const char *relationName,
* Grab an exclusive lock on the target table, which we will NOT release
* until end of transaction.
*/
rel
=
heap_openr
(
(
char
*
)
relationName
,
AccessExclusiveLock
);
rel
=
heap_openr
(
relationName
,
AccessExclusiveLock
);
myrelid
=
RelationGetRelid
(
rel
);
heap_close
(
rel
,
NoLock
);
/* close rel but keep lock! */
...
...
@@ -519,8 +520,7 @@ AlterTableAlterColumn(const char *relationName,
elog
(
ERROR
,
"ALTER TABLE: permission denied"
);
#endif
/* XXX should heap_openr take const char * ? */
rel
=
heap_openr
((
char
*
)
relationName
,
AccessExclusiveLock
);
rel
=
heap_openr
(
relationName
,
AccessExclusiveLock
);
myrelid
=
RelationGetRelid
(
rel
);
heap_close
(
rel
,
NoLock
);
...
...
@@ -626,7 +626,7 @@ AlterTableAlterColumn(const char *relationName,
/* keep the system catalog indices current */
CatalogOpenIndices
(
Num_pg_attr_indices
,
Name_pg_attr_indices
,
irelations
);
CatalogIndexInsert
(
irelations
,
Num_pg_attr_indices
,
attr_rel
,
newtuple
);
CatalogCloseIndices
(
Num_pg_
class
_indices
,
irelations
);
CatalogCloseIndices
(
Num_pg_
attrdef
_indices
,
irelations
);
/* get rid of actual default definition */
drop_default
(
myrelid
,
attnum
);
...
...
@@ -672,31 +672,234 @@ drop_default(Oid relid, int16 attnum)
/*
* ALTER TABLE DROP COLUMN
*
* Strategy:
* - permission/sanity checks
* - create a new table _ATDC<name> with all attributes minus the desired one
* - copy over all the data
* - make the column defaults point to the new table
* - kill the old table
* - rename the intermediate table back
*/
void
AlterTableDropColumn
(
const
char
*
relationName
,
bool
inh
,
const
char
*
colName
,
int
behavior
)
{
elog
(
NOTICE
,
"ALTER TABLE / DROP COLUMN is not implemented"
);
Relation
oldrel
,
newrel
,
defrel
;
HeapTuple
tuple
;
TupleDesc
olddesc
,
newdesc
,
defdsc
;
int16
dropattnum
,
oldnumatts
;
Oid
oldrel_oid
,
newrel_oid
;
char
tmpname
[
NAMEDATALEN
];
int16
i
;
HeapScanDesc
scan
;
ScanKeyData
scankey
;
if
(
!
allowSystemTableMods
&&
IsSystemRelationName
(
relationName
))
elog
(
ERROR
,
"ALTER TABLE: relation
\"
%s
\"
is a system catalog"
,
relationName
);
#ifndef NO_SECURITY
if
(
!
pg_ownercheck
(
UserName
,
relationName
,
RELNAME
))
elog
(
ERROR
,
"ALTER TABLE: permission denied"
);
#endif
oldrel
=
heap_openr
(
relationName
,
AccessExclusiveLock
);
if
(
oldrel
->
rd_rel
->
relkind
!=
RELKIND_RELATION
)
{
heap_close
(
oldrel
,
AccessExclusiveLock
);
elog
(
ERROR
,
"ALTER TABLE: relation %s is not a table"
,
relationName
);
}
oldrel_oid
=
ObjectIdGetDatum
(
RelationGetRelid
(
oldrel
));
oldnumatts
=
RelationGetNumberOfAttributes
(
oldrel
);
if
(
oldnumatts
==
1
)
{
heap_close
(
oldrel
,
AccessExclusiveLock
);
elog
(
ERROR
,
"ALTER TABLE: relation %s only has one column"
,
relationName
);
}
/* What to do here? */
/*
if (length(find_all_inheritors(RelationGetRelid(oldrel)))>0)
elog(ERROR, "ALTER TABLE: cannot drop a column on table that is inherited from");
*/
/*
* get the number of the attribute
*/
tuple
=
SearchSysCacheTuple
(
ATTNAME
,
oldrel_oid
,
NameGetDatum
(
namein
(
colName
)),
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
{
heap_close
(
oldrel
,
AccessExclusiveLock
);
elog
(
ERROR
,
"ALTER TABLE: relation
\"
%s
\"
has no column
\"
%s
\"
"
,
relationName
,
colName
);
}
dropattnum
=
((
Form_pg_attribute
)
GETSTRUCT
(
tuple
))
->
attnum
;
if
(
snprintf
(
tmpname
,
NAMEDATALEN
,
"_ATDC%s"
,
relationName
)
==-
1
)
{
heap_close
(
oldrel
,
AccessExclusiveLock
);
elog
(
ERROR
,
"AlterTableDropColumn: relation name too long"
);
}
/*
* Build descriptor for new relation
*/
olddesc
=
RelationGetDescr
(
oldrel
);
newdesc
=
CreateTemplateTupleDesc
(
oldnumatts
-
1
);
for
(
i
=
1
;
i
<
dropattnum
;
i
++
)
{
Form_pg_attribute
att
=
olddesc
->
attrs
[
i
-
1
];
TupleDescInitEntry
(
newdesc
,
i
,
nameout
(
&
(
att
->
attname
)),
att
->
atttypid
,
att
->
atttypmod
,
att
->
attnelems
,
att
->
attisset
);
/* the above function doesn't take care of these two */
newdesc
->
attrs
[
i
-
1
]
->
attnotnull
=
att
->
attnotnull
;
newdesc
->
attrs
[
i
-
1
]
->
atthasdef
=
att
->
atthasdef
;
}
for
(
i
=
dropattnum
;
i
<=
oldnumatts
-
1
;
i
++
)
{
Form_pg_attribute
att
=
olddesc
->
attrs
[
i
];
TupleDescInitEntry
(
newdesc
,
i
,
nameout
(
&
(
att
->
attname
)),
att
->
atttypid
,
att
->
atttypmod
,
att
->
attnelems
,
att
->
attisset
);
/* the above function doesn't take care of these two */
newdesc
->
attrs
[
i
-
1
]
->
attnotnull
=
att
->
attnotnull
;
newdesc
->
attrs
[
i
-
1
]
->
atthasdef
=
att
->
atthasdef
;
}
/* Create the new table */
newrel_oid
=
heap_create_with_catalog
(
tmpname
,
newdesc
,
RELKIND_RELATION
,
false
);
if
(
newrel_oid
==
InvalidOid
)
{
heap_close
(
oldrel
,
AccessExclusiveLock
);
elog
(
ERROR
,
"ALTER TABLE: something went wrong"
);
}
/* Make the new table visible */
CommandCounterIncrement
();
/*
* Copy over the data
*/
newrel
=
heap_open
(
newrel_oid
,
AccessExclusiveLock
);
scan
=
heap_beginscan
(
oldrel
,
false
,
SnapshotNow
,
0
,
NULL
);
while
(
HeapTupleIsValid
(
tuple
=
heap_getnext
(
scan
,
0
)))
{
bool
isnull
;
Datum
*
new_record
;
bool
*
new_record_nulls
;
HeapTuple
new_tuple
;
new_record
=
palloc
((
oldnumatts
-
1
)
*
sizeof
(
*
new_record
));
new_record_nulls
=
palloc
((
oldnumatts
-
1
)
*
sizeof
(
*
new_record_nulls
));
for
(
i
=
1
;
i
<
dropattnum
;
i
++
)
{
new_record
[
i
-
1
]
=
heap_getattr
(
tuple
,
i
,
olddesc
,
&
isnull
);
new_record_nulls
[
i
-
1
]
=
isnull
?
'n'
:
' '
;
}
for
(
i
=
dropattnum
+
1
;
i
<=
oldnumatts
;
i
++
)
{
new_record
[
i
-
2
]
=
heap_getattr
(
tuple
,
i
,
olddesc
,
&
isnull
);
new_record_nulls
[
i
-
2
]
=
isnull
?
'n'
:
' '
;
}
new_tuple
=
heap_formtuple
(
newdesc
,
new_record
,
new_record_nulls
);
Assert
(
new_tuple
);
if
(
heap_insert
(
newrel
,
new_tuple
)
==
InvalidOid
)
elog
(
ERROR
,
"AlterTableDropColumn: heap_insert failed"
);
pfree
(
new_record
);
pfree
(
new_record_nulls
);
}
heap_endscan
(
scan
);
heap_close
(
newrel
,
NoLock
);
heap_close
(
oldrel
,
NoLock
);
/*
* Move defaults over to the new table
*/
defrel
=
heap_openr
(
AttrDefaultRelationName
,
AccessExclusiveLock
);
defdsc
=
RelationGetDescr
(
defrel
);
/* look for all entries referencing the old table */
ScanKeyEntryInitialize
(
&
scankey
,
0x0
,
Anum_pg_attrdef_adrelid
,
F_OIDEQ
,
ObjectIdGetDatum
(
oldrel_oid
));
scan
=
heap_beginscan
(
defrel
,
false
,
SnapshotNow
,
1
,
&
scankey
);
while
(
HeapTupleIsValid
(
tuple
=
heap_getnext
(
scan
,
false
)))
{
HeapTuple
newtuple
;
int2
attrnum
;
Relation
irelations
[
Num_pg_attrdef_indices
];
attrnum
=
((
Form_pg_attrdef
)
GETSTRUCT
(
tuple
))
->
adnum
;
/* remove the entry about the dropped column */
if
(
attrnum
==
dropattnum
)
{
heap_delete
(
defrel
,
&
tuple
->
t_self
,
NULL
);
continue
;
}
newtuple
=
heap_copytuple
(
tuple
);
if
(
attrnum
>
dropattnum
)
((
Form_pg_attrdef
)
GETSTRUCT
(
newtuple
))
->
adnum
--
;
/* make it point to the new table */
((
Form_pg_attrdef
)
GETSTRUCT
(
newtuple
))
->
adrelid
=
newrel_oid
;
heap_update
(
defrel
,
&
tuple
->
t_self
,
newtuple
,
NULL
);
/* keep the system catalog indices current */
CatalogOpenIndices
(
Num_pg_attrdef_indices
,
Name_pg_attrdef_indices
,
irelations
);
CatalogIndexInsert
(
irelations
,
Num_pg_attrdef_indices
,
defrel
,
newtuple
);
CatalogCloseIndices
(
Num_pg_attrdef_indices
,
irelations
);
}
heap_endscan
(
scan
);
heap_close
(
defrel
,
NoLock
);
CommandCounterIncrement
();
/* make the old table disappear */
heap_drop_with_catalog
(
relationName
);
CommandCounterIncrement
();
/* set back original name */
TypeRename
(
tmpname
,
relationName
);
renamerel
(
tmpname
,
relationName
);
}
/*
* ALTER TABLE ADD CONSTRAINT
*/
void
AlterTableAddConstraint
(
const
char
*
relationName
,
bool
inh
,
Node
*
newConstraint
)
{
elog
(
NOTICE
,
"ALTER TABLE / ADD CONSTRAINT is not implemented"
);
elog
(
ERROR
,
"ALTER TABLE / ADD CONSTRAINT is not implemented"
);
}
void
AlterTableDropConstraint
(
const
char
*
relationName
,
/*
* ALTER TABLE DROP CONSTRAINT
*/
void
AlterTableDropConstraint
(
const
char
*
relationName
,
bool
inh
,
const
char
*
constrName
,
int
behavior
)
{
elog
(
NOTICE
,
"ALTER TABLE / DROP CONSTRAINT is not implemented"
);
elog
(
ERROR
,
"ALTER TABLE / DROP CONSTRAINT is not implemented"
);
}
...
...
src/backend/commands/rename.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.
39 1999/12/16 22:19:42 wieck
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.
40 2000/01/22 14:20:45 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -172,7 +172,7 @@ renameatt(char *relname,
* renamerel - change the name of a relation
*/
void
renamerel
(
c
har
*
oldrelname
,
char
*
newrelname
)
renamerel
(
c
onst
char
*
oldrelname
,
const
char
*
newrelname
)
{
int
i
;
Relation
targetrelation
;
...
...
src/backend/parser/gram.y
View file @
fa5400c0
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.13
2 2000/01/20 02:24:50 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.13
3 2000/01/22 14:20:46 petere
Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -830,14 +830,14 @@ AlterTableStmt:
$$ = (Node *)n;
}
/* ALTER TABLE <name> DROP [COLUMN] <name> {RESTRICT|CASCADE} */
| ALTER TABLE relation_name opt_inh_star DROP opt_column ColId
drop_behavior
| ALTER TABLE relation_name opt_inh_star DROP opt_column ColId
/* drop_behavior */
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
n->relname = $3;
n->inh = $4;
n->name = $7;
n->behavior = $8;
/* n->behavior = $8; */
$$ = (Node *)n;
}
/* ALTER TABLE <name> ADD CONSTRAINT ... */
...
...
src/backend/utils/adt/name.c
View file @
fa5400c0
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.2
5 1999/11/25 19:15:20 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.2
6 2000/01/22 14:20:49 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -31,7 +31,7 @@
* Now, always NULL terminated
*/
NameData
*
namein
(
char
*
s
)
namein
(
c
onst
c
har
*
s
)
{
NameData
*
result
;
int
len
;
...
...
@@ -54,7 +54,7 @@ namein(char *s)
* nameout - converts internal reprsentation to "..."
*/
char
*
nameout
(
NameData
*
s
)
nameout
(
const
NameData
*
s
)
{
if
(
s
==
NULL
)
return
"-"
;
...
...
@@ -82,7 +82,7 @@ nameout(NameData *s)
*
*/
bool
nameeq
(
NameData
*
arg1
,
NameData
*
arg2
)
nameeq
(
const
NameData
*
arg1
,
const
NameData
*
arg2
)
{
if
(
!
arg1
||
!
arg2
)
return
0
;
...
...
@@ -91,7 +91,7 @@ nameeq(NameData *arg1, NameData *arg2)
}
bool
namene
(
NameData
*
arg1
,
NameData
*
arg2
)
namene
(
const
NameData
*
arg1
,
const
NameData
*
arg2
)
{
if
(
arg1
==
NULL
||
arg2
==
NULL
)
return
(
bool
)
0
;
...
...
@@ -99,7 +99,7 @@ namene(NameData *arg1, NameData *arg2)
}
bool
namelt
(
NameData
*
arg1
,
NameData
*
arg2
)
namelt
(
const
NameData
*
arg1
,
const
NameData
*
arg2
)
{
if
(
arg1
==
NULL
||
arg2
==
NULL
)
return
(
bool
)
0
;
...
...
@@ -107,7 +107,7 @@ namelt(NameData *arg1, NameData *arg2)
}
bool
namele
(
NameData
*
arg1
,
NameData
*
arg2
)
namele
(
const
NameData
*
arg1
,
const
NameData
*
arg2
)
{
if
(
arg1
==
NULL
||
arg2
==
NULL
)
return
(
bool
)
0
;
...
...
@@ -115,7 +115,7 @@ namele(NameData *arg1, NameData *arg2)
}
bool
namegt
(
NameData
*
arg1
,
NameData
*
arg2
)
namegt
(
const
NameData
*
arg1
,
const
NameData
*
arg2
)
{
if
(
arg1
==
NULL
||
arg2
==
NULL
)
return
(
bool
)
0
;
...
...
@@ -124,7 +124,7 @@ namegt(NameData *arg1, NameData *arg2)
}
bool
namege
(
NameData
*
arg1
,
NameData
*
arg2
)
namege
(
const
NameData
*
arg1
,
const
NameData
*
arg2
)
{
if
(
arg1
==
NULL
||
arg2
==
NULL
)
return
(
bool
)
0
;
...
...
@@ -163,7 +163,7 @@ namecmp(Name n1, Name n2)
#endif
int
namestrcpy
(
Name
name
,
char
*
str
)
namestrcpy
(
Name
name
,
c
onst
c
har
*
str
)
{
if
(
!
name
||
!
str
)
return
-
1
;
...
...
@@ -173,7 +173,7 @@ namestrcpy(Name name, char *str)
#ifdef NOT_USED
int
namestrcat
(
Name
name
,
char
*
str
)
namestrcat
(
Name
name
,
c
onst
c
har
*
str
)
{
int
i
;
char
*
p
,
...
...
@@ -195,7 +195,7 @@ namestrcat(Name name, char *str)
#endif
int
namestrcmp
(
Name
name
,
char
*
str
)
namestrcmp
(
Name
name
,
c
onst
c
har
*
str
)
{
if
(
!
name
&&
!
str
)
return
0
;
...
...
src/backend/utils/cache/relcache.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.8
5 2000/01/15 02:59:39
petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.8
6 2000/01/22 14:20:50
petere Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -62,7 +62,7 @@
static
void
RelationClearRelation
(
Relation
relation
,
bool
rebuildIt
);
static
void
RelationFlushRelation
(
Relation
*
relationPtr
,
bool
onlyFlushReferenceCountZero
);
static
Relation
RelationNameCacheGetRelation
(
char
*
relationName
);
static
Relation
RelationNameCacheGetRelation
(
c
onst
c
har
*
relationName
);
static
void
RelationCacheAbortWalker
(
Relation
*
relationPtr
,
int
dummy
);
static
void
init_irels
(
void
);
...
...
@@ -1067,7 +1067,7 @@ RelationIdCacheGetRelation(Oid relationId)
* --------------------------------
*/
static
Relation
RelationNameCacheGetRelation
(
char
*
relationName
)
RelationNameCacheGetRelation
(
c
onst
c
har
*
relationName
)
{
Relation
rd
;
NameData
name
;
...
...
@@ -1144,7 +1144,7 @@ RelationIdGetRelation(Oid relationId)
* --------------------------------
*/
Relation
RelationNameGetRelation
(
char
*
relationName
)
RelationNameGetRelation
(
c
onst
c
har
*
relationName
)
{
char
*
temprelname
;
Relation
rd
;
...
...
@@ -1180,7 +1180,7 @@ RelationNameGetRelation(char *relationName)
* ----------------
*/
buildinfo
.
infotype
=
INFO_RELNAME
;
buildinfo
.
i
.
info_name
=
relationName
;
buildinfo
.
i
.
info_name
=
(
char
*
)
relationName
;
rd
=
RelationBuildDesc
(
buildinfo
,
NULL
);
return
rd
;
...
...
@@ -1727,7 +1727,7 @@ AttrDefaultFetch(Relation relation)
if
(
adform
->
adnum
!=
attrdef
[
i
].
adnum
)
continue
;
if
(
attrdef
[
i
].
adbin
!=
NULL
)
elog
(
ERROR
,
"AttrDefaultFetch: second record found for attr %s in rel %s"
,
elog
(
NOTICE
,
"AttrDefaultFetch: second record found for attr %s in rel %s"
,
NameStr
(
relation
->
rd_att
->
attrs
[
adform
->
adnum
-
1
]
->
attname
),
RelationGetRelationName
(
relation
));
...
...
@@ -1735,7 +1735,7 @@ AttrDefaultFetch(Relation relation)
Anum_pg_attrdef_adbin
,
adrel
->
rd_att
,
&
isnull
);
if
(
isnull
)
elog
(
ERROR
,
"AttrDefaultFetch: adbin IS NULL for attr %s in rel %s"
,
elog
(
NOTICE
,
"AttrDefaultFetch: adbin IS NULL for attr %s in rel %s"
,
NameStr
(
relation
->
rd_att
->
attrs
[
adform
->
adnum
-
1
]
->
attname
),
RelationGetRelationName
(
relation
));
attrdef
[
i
].
adbin
=
textout
(
val
);
...
...
@@ -1744,13 +1744,13 @@ AttrDefaultFetch(Relation relation)
ReleaseBuffer
(
buffer
);
if
(
i
>=
ndef
)
elog
(
ERROR
,
"AttrDefaultFetch: unexpected record found for attr %d in rel %s"
,
elog
(
NOTICE
,
"AttrDefaultFetch: unexpected record found for attr %d in rel %s"
,
adform
->
adnum
,
RelationGetRelationName
(
relation
));
}
if
(
found
<
ndef
)
elog
(
ERROR
,
"AttrDefaultFetch: %d record not found for rel %s"
,
elog
(
NOTICE
,
"AttrDefaultFetch: %d record not found for rel %s"
,
ndef
-
found
,
RelationGetRelationName
(
relation
));
index_endscan
(
sd
);
...
...
src/backend/utils/cache/temprel.c
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.1
8 1999/12/10 03:56:00 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.1
9 2000/01/22 14:20:50 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -49,7 +49,7 @@ typedef struct TempTable
void
create_temp_relation
(
char
*
relname
,
HeapTuple
pg_class_tuple
)
create_temp_relation
(
c
onst
c
har
*
relname
,
HeapTuple
pg_class_tuple
)
{
MemoryContext
oldcxt
;
TempTable
*
temp_rel
;
...
...
@@ -202,7 +202,7 @@ invalidate_temp_relations(void)
}
char
*
get_temp_rel_by_username
(
char
*
user_relname
)
get_temp_rel_by_username
(
c
onst
c
har
*
user_relname
)
{
List
*
l
;
...
...
@@ -217,7 +217,7 @@ get_temp_rel_by_username(char *user_relname)
}
char
*
get_temp_rel_by_physicalname
(
char
*
relname
)
get_temp_rel_by_physicalname
(
c
onst
c
har
*
relname
)
{
List
*
l
;
...
...
@@ -229,5 +229,5 @@ get_temp_rel_by_physicalname(char *relname)
return
temp_rel
->
user_relname
;
}
/* needed for bootstrapping temp tables */
return
relname
;
return
pstrdup
(
relname
)
;
}
src/bin/psql/command.c
View file @
fa5400c0
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Team
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.1
3 2000/01/18 23:30:22
petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.1
4 2000/01/22 14:20:51
petere Exp $
*/
#include <c.h>
#include "command.h"
...
...
@@ -1217,6 +1217,7 @@ process_file(char *filename)
pset
.
inputfile
=
filename
;
result
=
MainLoop
(
fd
);
fclose
(
fd
);
pset
.
inputfile
=
NULL
;
return
(
result
==
EXIT_SUCCESS
);
}
...
...
src/include/access/heapam.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: heapam.h,v 1.
49 1999/12/16 22:19:58 wieck
Exp $
* $Id: heapam.h,v 1.
50 2000/01/22 14:20:52 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -248,7 +248,7 @@ extern HeapAccessStatistics heap_access_stats; /* in stats.c */
/* heapam.c */
extern
Relation
heap_open
(
Oid
relationId
,
LOCKMODE
lockmode
);
extern
Relation
heap_openr
(
char
*
relationName
,
LOCKMODE
lockmode
);
extern
Relation
heap_openr
(
c
onst
c
har
*
relationName
,
LOCKMODE
lockmode
);
extern
void
heap_close
(
Relation
relation
,
LOCKMODE
lockmode
);
extern
HeapScanDesc
heap_beginscan
(
Relation
relation
,
int
atend
,
Snapshot
snapshot
,
unsigned
nkeys
,
ScanKey
key
);
...
...
src/include/catalog/heap.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: heap.h,v 1.2
6 1999/12/10 03:56:05 momjian
Exp $
* $Id: heap.h,v 1.2
7 2000/01/22 14:20:53 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -21,7 +21,7 @@ typedef struct RawColumnDefault
Node
*
raw_default
;
/* default value (untransformed parse tree) */
}
RawColumnDefault
;
extern
Oid
RelnameFindRelid
(
char
*
relname
);
extern
Oid
RelnameFindRelid
(
c
onst
c
har
*
relname
);
extern
Relation
heap_create
(
char
*
relname
,
TupleDesc
att
,
bool
isnoname
,
bool
istemp
,
bool
storage_create
);
extern
bool
heap_storage_create
(
Relation
rel
);
...
...
@@ -29,7 +29,7 @@ extern bool heap_storage_create(Relation rel);
extern
Oid
heap_create_with_catalog
(
char
*
relname
,
TupleDesc
tupdesc
,
char
relkind
,
bool
istemp
);
extern
void
heap_drop_with_catalog
(
char
*
relname
);
extern
void
heap_drop_with_catalog
(
c
onst
c
har
*
relname
);
extern
void
heap_truncate
(
char
*
relname
);
extern
void
heap_drop
(
Relation
rel
);
...
...
src/include/catalog/pg_type.h
View file @
fa5400c0
...
...
@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_type.h,v 1.7
7 2000/01/17 01:29:07 tgl
Exp $
* $Id: pg_type.h,v 1.7
8 2000/01/22 14:20:53 petere
Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
...
...
@@ -410,7 +410,7 @@ extern Oid TypeCreate(char *typeName,
char
*
elementTypeName
,
char
*
defaultTypeValue
,
bool
passedByValue
,
char
alignment
);
extern
void
TypeRename
(
c
har
*
oldTypeName
,
char
*
newTypeName
);
extern
void
TypeRename
(
c
onst
char
*
oldTypeName
,
const
char
*
newTypeName
);
extern
char
*
makeArrayTypeName
(
char
*
typeName
);
...
...
src/include/commands/rename.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rename.h,v 1.
6 1999/02/13 23:21:19 momjian
Exp $
* $Id: rename.h,v 1.
7 2000/01/22 14:20:54 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -18,7 +18,7 @@ extern void renameatt(char *relname,
char
*
newattname
,
char
*
userName
,
int
recurse
);
extern
void
renamerel
(
char
*
oldrelname
,
char
*
newrelname
);
extern
void
renamerel
(
c
onst
c
har
*
oldrelname
,
c
onst
c
har
*
newrelname
);
#endif
/* RENAME_H */
src/include/utils/builtins.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: builtins.h,v 1.9
5 2000/01/10 16:13:22 momjian
Exp $
* $Id: builtins.h,v 1.9
6 2000/01/22 14:20:55 petere
Exp $
*
* NOTES
* This should normally only be included by fmgr.h.
...
...
@@ -136,17 +136,17 @@ extern int32 int4larger(int32 arg1, int32 arg2);
extern
int32
int4smaller
(
int32
arg1
,
int32
arg2
);
/* name.c */
extern
NameData
*
namein
(
char
*
s
);
extern
char
*
nameout
(
NameData
*
s
);
extern
bool
nameeq
(
NameData
*
arg1
,
NameData
*
arg2
);
extern
bool
namene
(
NameData
*
arg1
,
NameData
*
arg2
);
extern
bool
namelt
(
NameData
*
arg1
,
NameData
*
arg2
);
extern
bool
namele
(
NameData
*
arg1
,
NameData
*
arg2
);
extern
bool
namegt
(
NameData
*
arg1
,
NameData
*
arg2
);
extern
bool
namege
(
NameData
*
arg1
,
NameData
*
arg2
);
extern
NameData
*
namein
(
c
onst
c
har
*
s
);
extern
char
*
nameout
(
const
NameData
*
s
);
extern
bool
nameeq
(
const
NameData
*
arg1
,
const
NameData
*
arg2
);
extern
bool
namene
(
const
NameData
*
arg1
,
const
NameData
*
arg2
);
extern
bool
namelt
(
const
NameData
*
arg1
,
const
NameData
*
arg2
);
extern
bool
namele
(
const
NameData
*
arg1
,
const
NameData
*
arg2
);
extern
bool
namegt
(
const
NameData
*
arg1
,
const
NameData
*
arg2
);
extern
bool
namege
(
const
NameData
*
arg1
,
const
NameData
*
arg2
);
extern
int
namecpy
(
Name
n1
,
Name
n2
);
extern
int
namestrcpy
(
Name
name
,
char
*
str
);
extern
int
namestrcmp
(
Name
name
,
char
*
str
);
extern
int
namestrcpy
(
Name
name
,
c
onst
c
har
*
str
);
extern
int
namestrcmp
(
Name
name
,
c
onst
c
har
*
str
);
/* numutils.c */
/* XXX hack. HP-UX has a ltoa (with different arguments) already. */
...
...
src/include/utils/rel.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rel.h,v 1.3
1 2000/01/10 17:14:44 momjian
Exp $
* $Id: rel.h,v 1.3
2 2000/01/22 14:20:56 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -176,7 +176,7 @@ typedef Relation *RelationPtr;
* Returns a Relation Name
*/
/* added to prevent circular dependency. bjm 1999/11/15 */
char
*
get_temp_rel_by_physicalname
(
char
*
relname
);
char
*
get_temp_rel_by_physicalname
(
c
onst
c
har
*
relname
);
#define RelationGetRelationName(relation) \
(\
(strncmp(RelationGetPhysicalRelationName(relation), \
...
...
src/include/utils/relcache.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: relcache.h,v 1.1
6 1999/11/21 01:58:20 tgl
Exp $
* $Id: relcache.h,v 1.1
7 2000/01/22 14:20:56 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,7 +20,7 @@
*/
extern
Relation
RelationIdCacheGetRelation
(
Oid
relationId
);
extern
Relation
RelationIdGetRelation
(
Oid
relationId
);
extern
Relation
RelationNameGetRelation
(
char
*
relationName
);
extern
Relation
RelationNameGetRelation
(
c
onst
c
har
*
relationName
);
extern
void
RelationClose
(
Relation
relation
);
extern
void
RelationForgetRelation
(
Oid
rid
);
...
...
src/include/utils/temprel.h
View file @
fa5400c0
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: temprel.h,v 1.
6 1999/11/16 04:14:03 momjian
Exp $
* $Id: temprel.h,v 1.
7 2000/01/22 14:20:56 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -15,11 +15,11 @@
#include "access/htup.h"
void
create_temp_relation
(
char
*
relname
,
HeapTuple
pg_class_tuple
);
void
create_temp_relation
(
c
onst
c
har
*
relname
,
HeapTuple
pg_class_tuple
);
void
remove_all_temp_relations
(
void
);
void
invalidate_temp_relations
(
void
);
void
remove_temp_relation
(
Oid
relid
);
char
*
get_temp_rel_by_username
(
char
*
user_relname
);
char
*
get_temp_rel_by_physicalname
(
char
*
relname
);
char
*
get_temp_rel_by_username
(
c
onst
c
har
*
user_relname
);
char
*
get_temp_rel_by_physicalname
(
c
onst
c
har
*
relname
);
#endif
/* TEMPREL_H */
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