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
290428dd
Commit
290428dd
authored
Oct 02, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for regproc so proc name can be supplied if unique, if not, oid.
parent
820f9f8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
39 deletions
+78
-39
src/backend/catalog/indexing.c
src/backend/catalog/indexing.c
+12
-6
src/backend/utils/adt/regproc.c
src/backend/utils/adt/regproc.c
+66
-33
No files found.
src/backend/catalog/indexing.c
View file @
290428dd
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.3
2 1998/09/23 04:21:59
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.3
3 1998/10/02 05:10:10
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -62,9 +62,9 @@ char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
...
@@ -62,9 +62,9 @@ char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
static
HeapTuple
CatalogIndexFetchTuple
(
Relation
heapRelation
,
static
HeapTuple
CatalogIndexFetchTuple
(
Relation
heapRelation
,
Relation
idesc
,
Relation
idesc
,
ScanKey
skey
,
ScanKey
skey
,
int16
num_keys
);
int16
num_keys
);
/*
/*
...
@@ -213,6 +213,7 @@ CatalogHasIndex(char *catName, Oid catId)
...
@@ -213,6 +213,7 @@ CatalogHasIndex(char *catName, Oid catId)
return
pgRelP
->
relhasindex
;
return
pgRelP
->
relhasindex
;
}
}
/*
/*
* CatalogIndexFetchTuple() -- Get a tuple that satisfies a scan key
* CatalogIndexFetchTuple() -- Get a tuple that satisfies a scan key
* from a catalog relation.
* from a catalog relation.
...
@@ -253,6 +254,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
...
@@ -253,6 +254,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
return
tuple
;
return
tuple
;
}
}
/*
/*
* The remainder of the file is for individual index scan routines. Each
* The remainder of the file is for individual index scan routines. Each
* index should be scanned according to how it was defined during bootstrap
* index should be scanned according to how it was defined during bootstrap
...
@@ -288,6 +290,7 @@ AttributeNameIndexScan(Relation heapRelation,
...
@@ -288,6 +290,7 @@ AttributeNameIndexScan(Relation heapRelation,
return
tuple
;
return
tuple
;
}
}
HeapTuple
HeapTuple
AttributeNumIndexScan
(
Relation
heapRelation
,
AttributeNumIndexScan
(
Relation
heapRelation
,
Oid
relid
,
Oid
relid
,
...
@@ -317,6 +320,7 @@ AttributeNumIndexScan(Relation heapRelation,
...
@@ -317,6 +320,7 @@ AttributeNumIndexScan(Relation heapRelation,
return
tuple
;
return
tuple
;
}
}
HeapTuple
HeapTuple
ProcedureOidIndexScan
(
Relation
heapRelation
,
Oid
procId
)
ProcedureOidIndexScan
(
Relation
heapRelation
,
Oid
procId
)
{
{
...
@@ -339,7 +343,6 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
...
@@ -339,7 +343,6 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
}
}
HeapTuple
HeapTuple
ProcedureNameIndexScan
(
Relation
heapRelation
,
ProcedureNameIndexScan
(
Relation
heapRelation
,
char
*
procName
,
char
*
procName
,
...
@@ -377,7 +380,6 @@ ProcedureNameIndexScan(Relation heapRelation,
...
@@ -377,7 +380,6 @@ ProcedureNameIndexScan(Relation heapRelation,
}
}
HeapTuple
HeapTuple
ProcedureSrcIndexScan
(
Relation
heapRelation
,
text
*
procSrc
)
ProcedureSrcIndexScan
(
Relation
heapRelation
,
text
*
procSrc
)
{
{
...
@@ -399,6 +401,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text *procSrc)
...
@@ -399,6 +401,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text *procSrc)
return
tuple
;
return
tuple
;
}
}
HeapTuple
HeapTuple
TypeOidIndexScan
(
Relation
heapRelation
,
Oid
typeId
)
TypeOidIndexScan
(
Relation
heapRelation
,
Oid
typeId
)
{
{
...
@@ -420,6 +423,7 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
...
@@ -420,6 +423,7 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
return
tuple
;
return
tuple
;
}
}
HeapTuple
HeapTuple
TypeNameIndexScan
(
Relation
heapRelation
,
char
*
typeName
)
TypeNameIndexScan
(
Relation
heapRelation
,
char
*
typeName
)
{
{
...
@@ -441,6 +445,7 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
...
@@ -441,6 +445,7 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
return
tuple
;
return
tuple
;
}
}
HeapTuple
HeapTuple
ClassNameIndexScan
(
Relation
heapRelation
,
char
*
relName
)
ClassNameIndexScan
(
Relation
heapRelation
,
char
*
relName
)
{
{
...
@@ -461,6 +466,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
...
@@ -461,6 +466,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
return
tuple
;
return
tuple
;
}
}
HeapTuple
HeapTuple
ClassOidIndexScan
(
Relation
heapRelation
,
Oid
relId
)
ClassOidIndexScan
(
Relation
heapRelation
,
Oid
relId
)
{
{
...
...
src/backend/utils/adt/regproc.c
View file @
290428dd
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.3
0 1998/09/25 03:36:33
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.3
1 1998/10/02 05:10:11
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -15,12 +15,16 @@
...
@@ -15,12 +15,16 @@
#include "postgres.h"
#include "postgres.h"
#include "miscadmin.h"
#include "miscadmin.h"
#include "access/heapam.h"
#include "access/heapam.h"
#include "access/genam.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/relscan.h"
#include "storage/bufmgr.h"
#include "fmgr.h"
#include "fmgr.h"
#include "utils/palloc.h"
#include "utils/palloc.h"
#include "utils/syscache.h"
#include "utils/syscache.h"
#include "catalog/catname.h"
#include "catalog/catname.h"
#include "catalog/indexing.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "catalog/pg_type.h"
#include "utils/builtins.h"
/* where function declarations go */
#include "utils/builtins.h"
/* where function declarations go */
...
@@ -30,45 +34,81 @@
...
@@ -30,45 +34,81 @@
*****************************************************************************/
*****************************************************************************/
/*
/*
* regprocin - converts "proname" to proid
* regprocin - converts "proname"
or "proid"
to proid
*
*
* proid of NULL signifies unknown
* proid of NULL signifies unknown
*/
*/
int32
int32
regprocin
(
char
*
pro_name_
and
_oid
)
regprocin
(
char
*
pro_name_
or
_oid
)
{
{
HeapTuple
proctup
=
NULL
;
HeapTuple
proctup
=
NULL
;
RegProcedure
result
=
(
Oid
)
0
;
RegProcedure
result
=
InvalidOid
;
if
(
pro_name_and_oid
==
NULL
)
return
0
;
if
(
pro_name_or_oid
==
NULL
)
return
InvalidOid
;
if
(
!
IsBootstrapProcessingMode
())
if
(
!
IsBootstrapProcessingMode
())
{
{
/*
/*
* we need to use the oid because there can be multiple entries
* we need to use the oid because there can be multiple entries
* with the same name. We accept int4eq_1323 and 1323.
* with the same name. We accept int4eq_1323 and 1323.
*/
*/
if
(
strrchr
(
pro_name_and_oid
,
'_'
)
!=
NULL
)
if
(
pro_name_or_oid
[
0
]
>=
'0'
&&
pro_name_or_oid
[
0
]
<=
'9'
)
{
{
proctup
=
SearchSysCacheTuple
(
PROOID
,
proctup
=
SearchSysCacheTuple
(
PROOID
,
ObjectIdGetDatum
(
atoi
(
strrchr
(
pro_name_and_oid
,
'_'
)
+
1
)),
ObjectIdGetDatum
(
oidin
(
pro_name_or_oid
)),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
HeapTupleIsValid
(
proctup
))
result
=
(
RegProcedure
)
proctup
->
t_oid
;
else
elog
(
ERROR
,
"No such procedure with oid %s"
,
pro_name_or_oid
);
}
}
else
if
(
atoi
(
pro_name_and_oid
)
!=
InvalidOid
)
else
{
{
proctup
=
SearchSysCacheTuple
(
PROOID
,
Relation
hdesc
;
/* atoi stops at the _ */
Relation
idesc
;
ObjectIdGetDatum
(
atoi
(
pro_name_and_oid
)),
IndexScanDesc
sd
;
0
,
0
,
0
);
ScanKeyData
skey
[
1
];
RetrieveIndexResult
indexRes
;
Buffer
buffer
;
int
matches
=
0
;
ScanKeyEntryInitialize
(
&
skey
[
0
],
(
bits16
)
0x0
,
(
AttrNumber
)
1
,
(
RegProcedure
)
F_NAMEEQ
,
PointerGetDatum
(
pro_name_or_oid
));
hdesc
=
heap_openr
(
ProcedureRelationName
);
idesc
=
index_openr
(
ProcedureNameIndex
);
sd
=
index_beginscan
(
idesc
,
false
,
1
,
skey
);
while
((
indexRes
=
index_getnext
(
sd
,
ForwardScanDirection
)))
{
proctup
=
heap_fetch
(
hdesc
,
SnapshotNow
,
&
indexRes
->
heap_iptr
,
&
buffer
);
pfree
(
indexRes
);
if
(
HeapTupleIsValid
(
proctup
))
{
result
=
(
RegProcedure
)
proctup
->
t_oid
;
ReleaseBuffer
(
buffer
);
if
(
++
matches
>
1
)
break
;
}
}
index_endscan
(
sd
);
pfree
(
sd
);
index_close
(
idesc
);
if
(
matches
>
1
)
elog
(
ERROR
,
"There is more than one %s procedure, supply oid in quotes."
,
pro_name_or_oid
);
else
if
(
matches
==
0
)
elog
(
ERROR
,
"No such procedure %s"
,
pro_name_or_oid
);
}
}
if
(
HeapTupleIsValid
(
proctup
))
result
=
(
RegProcedure
)
proctup
->
t_oid
;
else
elog
(
ERROR
,
"regprocin: no such procedure %s"
,
pro_name_and_oid
);
}
}
else
else
{
{
...
@@ -88,7 +128,7 @@ regprocin(char *pro_name_and_oid)
...
@@ -88,7 +128,7 @@ regprocin(char *pro_name_and_oid)
(
bits16
)
0
,
(
bits16
)
0
,
(
AttrNumber
)
1
,
(
AttrNumber
)
1
,
(
RegProcedure
)
F_NAMEEQ
,
(
RegProcedure
)
F_NAMEEQ
,
(
Datum
)
pro_name_
and
_oid
);
(
Datum
)
pro_name_
or
_oid
);
procscan
=
heap_beginscan
(
proc
,
0
,
SnapshotNow
,
1
,
&
key
);
procscan
=
heap_beginscan
(
proc
,
0
,
SnapshotNow
,
1
,
&
key
);
if
(
!
HeapScanIsValid
(
procscan
))
if
(
!
HeapScanIsValid
(
procscan
))
...
@@ -106,7 +146,7 @@ regprocin(char *pro_name_and_oid)
...
@@ -106,7 +146,7 @@ regprocin(char *pro_name_and_oid)
RelationGetDescr
(
proc
),
RelationGetDescr
(
proc
),
&
isnull
);
&
isnull
);
if
(
isnull
)
if
(
isnull
)
elog
(
FATAL
,
"regprocin: null procedure %s"
,
pro_name_
and
_oid
);
elog
(
FATAL
,
"regprocin: null procedure %s"
,
pro_name_
or
_oid
);
}
}
else
else
result
=
(
RegProcedure
)
0
;
result
=
(
RegProcedure
)
0
;
...
@@ -115,14 +155,11 @@ regprocin(char *pro_name_and_oid)
...
@@ -115,14 +155,11 @@ regprocin(char *pro_name_and_oid)
heap_close
(
proc
);
heap_close
(
proc
);
}
}
#ifdef EBUG
elog
(
DEBUG
,
"regprocin: no such procedure %s"
,
pro_name_and_oid
);
#endif
/* defined(EBUG) */
return
(
int32
)
result
;
return
(
int32
)
result
;
}
}
/*
/*
* regprocout - converts proid to "pro_name
_and_oid
"
* regprocout - converts proid to "pro_name"
*/
*/
char
*
char
*
regprocout
(
RegProcedure
proid
)
regprocout
(
RegProcedure
proid
)
...
@@ -143,7 +180,7 @@ regprocout(RegProcedure proid)
...
@@ -143,7 +180,7 @@ regprocout(RegProcedure proid)
char
*
s
;
char
*
s
;
s
=
((
Form_pg_proc
)
GETSTRUCT
(
proctup
))
->
proname
.
data
;
s
=
((
Form_pg_proc
)
GETSTRUCT
(
proctup
))
->
proname
.
data
;
snprintf
(
result
,
NAMEDATALEN
,
"%s_%d"
,
s
,
proid
);
StrNCpy
(
result
,
s
,
NAMEDATALEN
);
}
}
else
else
{
{
...
@@ -160,8 +197,7 @@ regprocout(RegProcedure proid)
...
@@ -160,8 +197,7 @@ regprocout(RegProcedure proid)
proc
=
heap_openr
(
ProcedureRelationName
);
proc
=
heap_openr
(
ProcedureRelationName
);
if
(
!
RelationIsValid
(
proc
))
if
(
!
RelationIsValid
(
proc
))
{
{
elog
(
ERROR
,
"regprocout: could not open %s"
,
elog
(
ERROR
,
"regprocout: could not open %s"
,
ProcedureRelationName
);
ProcedureRelationName
);
return
0
;
return
0
;
}
}
ScanKeyEntryInitialize
(
&
key
,
ScanKeyEntryInitialize
(
&
key
,
...
@@ -201,9 +237,6 @@ regprocout(RegProcedure proid)
...
@@ -201,9 +237,6 @@ regprocout(RegProcedure proid)
return
result
;
return
result
;
}
}
#ifdef EBUG
elog
(
DEBUG
,
"regprocout: no such procedure %d"
,
proid
);
#endif
/* defined(EBUG) */
return
result
;
return
result
;
}
}
...
...
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