Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
75586cb5
Commit
75586cb5
authored
23 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Disallow non-cachable functions in functional indexes and in index
predicates. Per suggestion from Hiroshi.
parent
84a36344
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/commands/indexcmds.c
+24
-2
24 additions, 2 deletions
src/backend/commands/indexcmds.c
with
24 additions
and
2 deletions
src/backend/commands/indexcmds.c
+
24
−
2
View file @
75586cb5
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
*
*
* indexcmds.c
* indexcmds.c
* POSTGRES define
, extend
and remove index code.
* POSTGRES define and remove index code.
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.5
2
2001/07/1
6 05:06:57
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.5
3
2001/07/1
7 21:53:01
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -39,8 +39,10 @@
...
@@ -39,8 +39,10 @@
#include
"parser/parse_type.h"
#include
"parser/parse_type.h"
#include
"utils/builtins.h"
#include
"utils/builtins.h"
#include
"utils/fmgroids.h"
#include
"utils/fmgroids.h"
#include
"utils/lsyscache.h"
#include
"utils/syscache.h"
#include
"utils/syscache.h"
#define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args != NIL)
#define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args != NIL)
/* non-export function prototypes */
/* non-export function prototypes */
...
@@ -232,10 +234,21 @@ CheckPredicate(List *predList, List *rangeTable, Oid baseRelOid)
...
@@ -232,10 +234,21 @@ CheckPredicate(List *predList, List *rangeTable, Oid baseRelOid)
elog
(
ERROR
,
elog
(
ERROR
,
"Partial-index predicates may refer only to the base relation"
);
"Partial-index predicates may refer only to the base relation"
);
/*
* We don't currently support generation of an actual query plan for a
* predicate, only simple scalar expressions; hence these restrictions.
*/
if
(
contain_subplans
((
Node
*
)
predList
))
if
(
contain_subplans
((
Node
*
)
predList
))
elog
(
ERROR
,
"Cannot use subselect in index predicate"
);
elog
(
ERROR
,
"Cannot use subselect in index predicate"
);
if
(
contain_agg_clause
((
Node
*
)
predList
))
if
(
contain_agg_clause
((
Node
*
)
predList
))
elog
(
ERROR
,
"Cannot use aggregate in index predicate"
);
elog
(
ERROR
,
"Cannot use aggregate in index predicate"
);
/*
* A predicate using noncachable functions is probably wrong, for the
* same reasons that we don't allow a functional index to use one.
*/
if
(
contain_noncachable_functions
((
Node
*
)
predList
))
elog
(
ERROR
,
"Cannot use non-cachable function in index predicate"
);
}
}
...
@@ -308,6 +321,15 @@ FuncIndexArgs(IndexInfo *indexInfo,
...
@@ -308,6 +321,15 @@ FuncIndexArgs(IndexInfo *indexInfo,
"Index function must be binary-compatible with table datatype"
);
"Index function must be binary-compatible with table datatype"
);
}
}
/*
* Require that the function be marked cachable. Using a noncachable
* function for a functional index is highly questionable, since if you
* aren't going to get the same result for the same data every time,
* it's not clear what the index entries mean at all.
*/
if
(
!
func_iscachable
(
funcid
))
elog
(
ERROR
,
"DefineIndex: index function must be marked iscachable"
);
/* Process opclass, using func return type as default type */
/* Process opclass, using func return type as default type */
classOidP
[
0
]
=
GetAttrOpClass
(
funcIndex
,
rettype
,
classOidP
[
0
]
=
GetAttrOpClass
(
funcIndex
,
rettype
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment