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
dc5c7713
Commit
dc5c7713
authored
Nov 16, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit to make clearer distinction for temp names and real names.
Thanks to Tom Lane for ideas.
parent
bf5d51e7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
70 additions
and
33 deletions
+70
-33
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+8
-8
src/backend/catalog/index.c
src/backend/catalog/index.c
+6
-6
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/bufmgr.c
+2
-2
src/backend/storage/smgr/md.c
src/backend/storage/smgr/md.c
+4
-4
src/backend/utils/cache/relcache.c
src/backend/utils/cache/relcache.c
+3
-3
src/backend/utils/cache/syscache.c
src/backend/utils/cache/syscache.c
+2
-2
src/backend/utils/cache/temprel.c
src/backend/utils/cache/temprel.c
+21
-3
src/include/utils/rel.h
src/include/utils/rel.h
+21
-3
src/include/utils/temprel.h
src/include/utils/temprel.h
+3
-2
No files found.
src/backend/catalog/heap.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.10
7 1999/11/07 23:08:00
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.10
8 1999/11/16 04:13:55
momjian Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -290,7 +290,7 @@ heap_create(char *relname,
* ----------------
*/
MemSet
((
char
*
)
rel
->
rd_rel
,
0
,
sizeof
*
rel
->
rd_rel
);
strcpy
(
RelationGetRelationName
(
rel
),
relname
);
strcpy
(
RelationGet
Physical
RelationName
(
rel
),
relname
);
rel
->
rd_rel
->
relkind
=
RELKIND_UNCATALOGED
;
rel
->
rd_rel
->
relnatts
=
natts
;
if
(
tupDesc
->
constr
)
...
...
@@ -798,7 +798,7 @@ heap_create_with_catalog(char *relname,
/* temp tables can mask non-temp tables */
if
((
!
istemp
&&
RelnameFindRelid
(
relname
))
||
(
istemp
&&
get_temp_rel_by_name
(
relname
)
!=
NULL
))
(
istemp
&&
get_temp_rel_by_
user
name
(
relname
)
!=
NULL
))
elog
(
ERROR
,
"Relation '%s' already exists"
,
relname
);
/* save user relation name because heap_create changes it */
...
...
@@ -810,7 +810,7 @@ heap_create_with_catalog(char *relname,
}
/* ----------------
* get_temp_rel_by_name() couldn't check the simultaneous
* get_temp_rel_by_
user
name() couldn't check the simultaneous
* creation. Uniqueness will be really checked by unique
* indexes of system tables but we couldn't check it here.
* We have to pospone to create the disk file for this
...
...
@@ -1448,7 +1448,7 @@ heap_destroy_with_catalog(char *relname)
{
Relation
rel
;
Oid
rid
;
bool
istemp
=
(
get_temp_rel_by_name
(
relname
)
!=
NULL
);
bool
istemp
=
(
get_temp_rel_by_
user
name
(
relname
)
!=
NULL
);
/* ----------------
* Open and lock the relation.
...
...
@@ -1518,9 +1518,6 @@ heap_destroy_with_catalog(char *relname)
DeleteComments
(
RelationGetRelid
(
rel
));
if
(
istemp
)
remove_temp_relation
(
rid
);
/* ----------------
* delete type tuple. here we want to see the effects
* of the deletions we just did, so we use setheapoverride().
...
...
@@ -1565,6 +1562,9 @@ heap_destroy_with_catalog(char *relname)
* ----------------
*/
RelationForgetRelation
(
rid
);
if
(
istemp
)
remove_temp_relation
(
rid
);
}
/*
...
...
src/backend/catalog/index.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.9
4 1999/11/04 08:00:56 inoue
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.9
5 1999/11/16 04:13:55 momjian
Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -120,7 +120,7 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp)
indoid
=
RelnameFindRelid
(
indexRelationName
);
if
((
!
istemp
&&
OidIsValid
(
indoid
))
||
(
istemp
&&
get_temp_rel_by_name
(
indexRelationName
)
!=
NULL
))
(
istemp
&&
get_temp_rel_by_
user
name
(
indexRelationName
)
!=
NULL
))
elog
(
ERROR
,
"Cannot create index: '%s' already exists"
,
indexRelationName
);
...
...
@@ -948,7 +948,7 @@ index_create(char *heapRelationName,
Oid
heapoid
;
Oid
indexoid
;
PredInfo
*
predInfo
;
bool
istemp
=
(
get_temp_rel_by_name
(
heapRelationName
)
!=
NULL
);
bool
istemp
=
(
get_temp_rel_by_
user
name
(
heapRelationName
)
!=
NULL
);
char
*
temp_relname
=
NULL
;
/* ----------------
...
...
@@ -1182,9 +1182,6 @@ index_destroy(Oid indexId)
}
heap_close
(
attributeRelation
,
RowExclusiveLock
);
/* does something only if it is a temp index */
remove_temp_relation
(
indexId
);
/* ----------------
* fix INDEX relation
* ----------------
...
...
@@ -1211,6 +1208,9 @@ index_destroy(Oid indexId)
index_close
(
userindexRelation
);
RelationForgetRelation
(
indexId
);
/* does something only if it is a temp index */
remove_temp_relation
(
indexId
);
}
/* ----------------------------------------------------------------
...
...
src/backend/storage/buffer/bufmgr.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.6
5 1999/11/07 23:08:14
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.6
6 1999/11/16 04:13:56
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -622,7 +622,7 @@ BufferAlloc(Relation reln,
}
/* record the database name and relation name for this buffer */
strcpy
(
buf
->
sb_relname
,
RelationGetRelationName
(
reln
));
strcpy
(
buf
->
sb_relname
,
RelationGet
Physical
RelationName
(
reln
));
strcpy
(
buf
->
sb_dbname
,
DatabaseName
);
INIT_BUFFERTAG
(
&
(
buf
->
tag
),
reln
,
blockNum
);
...
...
src/backend/storage/smgr/md.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.
59 1999/11/07 23:08:19
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.
60 1999/11/16 04:13:56
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -121,7 +121,7 @@ mdcreate(Relation reln)
char
*
path
;
Assert
(
reln
->
rd_unlinked
&&
reln
->
rd_fd
<
0
);
path
=
relpath
(
RelationGetRelationName
(
reln
));
path
=
relpath
(
RelationGet
Physical
RelationName
(
reln
));
#ifndef __CYGWIN32__
fd
=
FileNameOpenFile
(
path
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
#else
...
...
@@ -319,7 +319,7 @@ mdopen(Relation reln)
int
vfd
;
Assert
(
reln
->
rd_fd
<
0
);
path
=
relpath
(
RelationGetRelationName
(
reln
));
path
=
relpath
(
RelationGet
Physical
RelationName
(
reln
));
#ifndef __CYGWIN32__
fd
=
FileNameOpenFile
(
path
,
O_RDWR
,
0600
);
...
...
@@ -1011,7 +1011,7 @@ _mdfd_openseg(Relation reln, int segno, int oflags)
*
fullpath
;
/* be sure we have enough space for the '.segno', if any */
path
=
relpath
(
RelationGetRelationName
(
reln
));
path
=
relpath
(
RelationGet
Physical
RelationName
(
reln
));
dofree
=
false
;
if
(
segno
>
0
)
...
...
src/backend/utils/cache/relcache.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.7
6 1999/11/07 23:08:26
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.7
7 1999/11/16 04:13:58
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -962,7 +962,7 @@ formrdesc(char *relationName,
relation
->
rd_rel
=
(
Form_pg_class
)
palloc
((
Size
)
(
sizeof
(
*
relation
->
rd_rel
)));
MemSet
(
relation
->
rd_rel
,
0
,
sizeof
(
FormData_pg_class
));
strcpy
(
RelationGetRelationName
(
relation
),
relationName
);
strcpy
(
RelationGet
Physical
RelationName
(
relation
),
relationName
);
/* ----------------
initialize attribute tuple form
...
...
@@ -1177,7 +1177,7 @@ RelationNameGetRelation(char *relationName)
* we only index temp rels by their real names.
* ----------------
*/
temprelname
=
get_temp_rel_by_name
(
relationName
);
temprelname
=
get_temp_rel_by_
user
name
(
relationName
);
if
(
temprelname
)
relationName
=
temprelname
;
...
...
src/backend/utils/cache/syscache.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.3
8 1999/11/01 02:29:25
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.3
9 1999/11/16 04:13:59
momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
...
...
@@ -472,7 +472,7 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */
char
*
nontemp_relname
;
if
((
nontemp_relname
=
get_temp_rel_by_name
(
DatumGetPointer
(
key1
)))
!=
NULL
)
get_temp_rel_by_
user
name
(
DatumGetPointer
(
key1
)))
!=
NULL
)
key1
=
PointerGetDatum
(
nontemp_relname
);
}
...
...
src/backend/utils/cache/temprel.c
View file @
dc5c7713
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.1
5 1999/11/07 23:08:26
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.1
6 1999/11/16 04:13:59
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -150,7 +150,6 @@ remove_temp_relation(Oid relid)
prev
=
l
;
l
=
lnext
(
l
);
}
}
MemoryContextSwitchTo
(
oldcxt
);
...
...
@@ -203,7 +202,7 @@ invalidate_temp_relations(void)
}
char
*
get_temp_rel_by_name
(
char
*
user_relname
)
get_temp_rel_by_
user
name
(
char
*
user_relname
)
{
List
*
l
;
...
...
@@ -216,3 +215,22 @@ get_temp_rel_by_name(char *user_relname)
}
return
NULL
;
}
char
*
get_temp_rel_by_physicalname
(
char
*
relname
)
{
List
*
l
;
/* already physical, needed for bootstrapping temp tables */
if
(
strncmp
(
relname
,
"pg_temp."
,
strlen
(
"pg_temp."
))
==
0
)
return
relname
;
foreach
(
l
,
temp_rels
)
{
TempTable
*
temp_rel
=
lfirst
(
l
);
if
(
strcmp
(
temp_rel
->
relname
,
relname
)
==
0
)
return
temp_rel
->
user_relname
;
}
return
NULL
;
}
src/include/utils/rel.h
View file @
dc5c7713
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: rel.h,v 1.
29 1999/11/07 23:08:3
3 momjian Exp $
* $Id: rel.h,v 1.
30 1999/11/16 04:14:0
3 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,7 +20,6 @@
#include "rewrite/prs2lock.h"
#include "storage/fd.h"
/*
* LockRelId and LockInfo really belong to lmgr.h, but it's more convenient
* to declare them here so we can have a LockInfoData field in a Relation.
...
...
@@ -176,7 +175,26 @@ typedef Relation *RelationPtr;
*
* Returns a Relation Name
*/
#define RelationGetRelationName(relation) (NameStr((relation)->rd_rel->relname))
/* added to prevent circular dependency. bjm 1999/11/15 */
char
*
get_temp_rel_by_physicalname
(
char
*
relname
);
#define RelationGetRelationName(relation) \
(\
(strncmp(RelationGetPhysicalRelationName(relation), \
"pg_temp.", strlen("pg_temp.")) != 0) \
? \
RelationGetPhysicalRelationName(relation) \
: \
get_temp_rel_by_physicalname( \
RelationGetPhysicalRelationName(relation)) \
)
/*
* RelationGetPhysicalRelationName
*
* Returns a Relation Name
*/
#define RelationGetPhysicalRelationName(relation) (NameStr((relation)->rd_rel->relname))
/*
* RelationGetNumberOfAttributes
...
...
src/include/utils/temprel.h
View file @
dc5c7713
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: temprel.h,v 1.
5 1999/09/04 19:55:50
momjian Exp $
* $Id: temprel.h,v 1.
6 1999/11/16 04:14:03
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -19,6 +19,7 @@ void create_temp_relation(char *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_name
(
char
*
user_relname
);
char
*
get_temp_rel_by_username
(
char
*
user_relname
);
char
*
get_temp_rel_by_physicalname
(
char
*
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