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
f46c1f1e
Commit
f46c1f1e
authored
Apr 25, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that user-specified opclass in CREATE INDEX corresponds to operators
that will actually work on the column datatype.
parent
e3087868
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
2 deletions
+41
-2
src/backend/commands/indexcmds.c
src/backend/commands/indexcmds.c
+41
-2
No files found.
src/backend/commands/indexcmds.c
View file @
f46c1f1e
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.2
4 2000/04/23 01:44:55
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.2
5 2000/04/25 02:45:54
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -24,6 +24,7 @@
#include "catalog/pg_database.h"
#include "catalog/pg_index.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_shadow.h"
#include "catalog/pg_type.h"
...
...
@@ -32,6 +33,7 @@
#include "optimizer/planmain.h"
#include "optimizer/prep.h"
#include "parser/parsetree.h"
#include "parser/parse_coerce.h"
#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "utils/builtins.h"
...
...
@@ -556,7 +558,9 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
HeapScanDesc
scan
;
ScanKeyData
entry
[
2
];
HeapTuple
tuple
;
Oid
opClassId
;
Oid
opClassId
,
oprId
;
bool
doTypeCheck
=
true
;
if
(
attribute
->
class
==
NULL
)
{
...
...
@@ -565,6 +569,8 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
if
(
attribute
->
class
==
NULL
)
elog
(
ERROR
,
"DefineIndex: type %s has no default operator class"
,
typeidTypeName
(
attrType
));
/* assume we need not check type compatibility */
doTypeCheck
=
false
;
}
tuple
=
SearchSysCacheTuple
(
CLANAME
,
...
...
@@ -597,9 +603,42 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
attribute
->
class
,
accessMethodName
);
}
oprId
=
((
Form_pg_amop
)
GETSTRUCT
(
tuple
))
->
amopopr
;
heap_endscan
(
scan
);
heap_close
(
relation
,
AccessShareLock
);
/*
* Make sure the operators associated with this opclass actually accept
* the column data type. This prevents possible coredumps caused by
* user errors like applying text_ops to an int4 column. We will accept
* an opclass as OK if the operator's input datatype is binary-compatible
* with the actual column datatype. Note we assume that all the operators
* associated with an opclass accept the same datatypes, so checking the
* first one we happened to find in the table is sufficient.
*
* If the opclass was the default for the datatype, assume we can skip
* this check --- that saves a few cycles in the most common case.
* If pg_opclass is messed up then we're probably screwed anyway...
*/
if
(
doTypeCheck
)
{
tuple
=
SearchSysCacheTuple
(
OPEROID
,
ObjectIdGetDatum
(
oprId
),
0
,
0
,
0
);
if
(
HeapTupleIsValid
(
tuple
))
{
Form_pg_operator
optup
=
(
Form_pg_operator
)
GETSTRUCT
(
tuple
);
Oid
opInputType
=
(
optup
->
oprkind
==
'l'
)
?
optup
->
oprright
:
optup
->
oprleft
;
if
(
attrType
!=
opInputType
&&
!
IS_BINARY_COMPATIBLE
(
attrType
,
opInputType
))
elog
(
ERROR
,
"DefineIndex: opclass
\"
%s
\"
does not accept datatype
\"
%s
\"
"
,
attribute
->
class
,
typeidTypeName
(
attrType
));
}
}
return
opClassId
;
}
...
...
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