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
4fe8ba63
Commit
4fe8ba63
authored
18 years ago
by
Teodor Sigaev
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug corrupting query in gist consistent function.
Thank to Mario Weilguni <mweilguni@sime.com> to discover a bug.
parent
c713683f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/ltree/_ltree_gist.c
+1
-0
1 addition, 0 deletions
contrib/ltree/_ltree_gist.c
contrib/ltree/ltree.h
+4
-1
4 additions, 1 deletion
contrib/ltree/ltree.h
contrib/ltree/ltree_gist.c
+14
-2
14 additions, 2 deletions
contrib/ltree/ltree_gist.c
with
19 additions
and
3 deletions
contrib/ltree/_ltree_gist.c
+
1
−
0
View file @
4fe8ba63
...
...
@@ -580,5 +580,6 @@ _ltree_consistent(PG_FUNCTION_ARGS)
/* internal error */
elog
(
ERROR
,
"unrecognized StrategyNumber: %d"
,
strategy
);
}
PG_FREE_IF_COPY
(
query
,
1
);
PG_RETURN_BOOL
(
res
);
}
This diff is collapsed.
Click to expand it.
contrib/ltree/ltree.h
+
4
−
1
View file @
4fe8ba63
/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.1
5
2006/0
3
/11
04:38:29 momjian
Exp $ */
/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.1
6
2006/0
7
/11
16:00:44 teodor
Exp $ */
#ifndef __LTREE_H__
#define __LTREE_H__
...
...
@@ -163,8 +163,11 @@ bool compare_subnode(ltree_level * t, char *q, int len,
ltree
*
lca_inner
(
ltree
**
a
,
int
len
);
#define PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
#define PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
#define PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
#define PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
#define PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
#define PG_GETARG_LTXTQUERY_COPY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
/* GiST support for ltree */
...
...
This diff is collapsed.
Click to expand it.
contrib/ltree/ltree_gist.c
+
14
−
2
View file @
4fe8ba63
/*
* GiST support for ltree
* Teodor Sigaev <teodor@stack.net>
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.1
5
2006/0
6/28 11:59:59
teodor Exp $
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.1
6
2006/0
7/11 16:00:44
teodor Exp $
*/
#include
"ltree.h"
...
...
@@ -627,7 +627,7 @@ Datum
ltree_consistent
(
PG_FUNCTION_ARGS
)
{
GISTENTRY
*
entry
=
(
GISTENTRY
*
)
PG_GETARG_POINTER
(
0
);
char
*
query
=
(
char
*
)
DatumGetPointer
(
PG_DETOAST_DATUM
(
PG_GETARG_DATUM
(
1
)))
;
void
*
query
=
NULL
;
ltree_gist
*
key
=
(
ltree_gist
*
)
DatumGetPointer
(
entry
->
key
);
StrategyNumber
strategy
=
(
StrategyNumber
)
PG_GETARG_UINT16
(
2
);
bool
res
=
false
;
...
...
@@ -635,15 +635,18 @@ ltree_consistent(PG_FUNCTION_ARGS)
switch
(
strategy
)
{
case
BTLessStrategyNumber
:
query
=
PG_GETARG_LTREE
(
1
);
res
=
(
GIST_LEAF
(
entry
))
?
(
ltree_compare
((
ltree
*
)
query
,
LTG_NODE
(
key
))
>
0
)
:
(
ltree_compare
((
ltree
*
)
query
,
LTG_GETLNODE
(
key
))
>=
0
);
break
;
case
BTLessEqualStrategyNumber
:
query
=
PG_GETARG_LTREE
(
1
);
res
=
(
ltree_compare
((
ltree
*
)
query
,
LTG_GETLNODE
(
key
))
>=
0
);
break
;
case
BTEqualStrategyNumber
:
query
=
PG_GETARG_LTREE
(
1
);
if
(
GIST_LEAF
(
entry
))
res
=
(
ltree_compare
((
ltree
*
)
query
,
LTG_NODE
(
key
))
==
0
);
else
...
...
@@ -654,21 +657,25 @@ ltree_consistent(PG_FUNCTION_ARGS)
);
break
;
case
BTGreaterEqualStrategyNumber
:
query
=
PG_GETARG_LTREE
(
1
);
res
=
(
ltree_compare
((
ltree
*
)
query
,
LTG_GETRNODE
(
key
))
<=
0
);
break
;
case
BTGreaterStrategyNumber
:
query
=
PG_GETARG_LTREE
(
1
);
res
=
(
GIST_LEAF
(
entry
))
?
(
ltree_compare
((
ltree
*
)
query
,
LTG_GETRNODE
(
key
))
<
0
)
:
(
ltree_compare
((
ltree
*
)
query
,
LTG_GETRNODE
(
key
))
<=
0
);
break
;
case
10
:
query
=
PG_GETARG_LTREE_COPY
(
1
);
res
=
(
GIST_LEAF
(
entry
))
?
inner_isparent
((
ltree
*
)
query
,
LTG_NODE
(
key
))
:
gist_isparent
(
key
,
(
ltree
*
)
query
);
break
;
case
11
:
query
=
PG_GETARG_LTREE_COPY
(
1
);
res
=
(
GIST_LEAF
(
entry
))
?
inner_isparent
(
LTG_NODE
(
key
),
(
ltree
*
)
query
)
:
...
...
@@ -676,6 +683,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
break
;
case
12
:
case
13
:
query
=
PG_GETARG_LQUERY
(
1
);
if
(
GIST_LEAF
(
entry
))
res
=
DatumGetBool
(
DirectFunctionCall2
(
ltq_regex
,
PointerGetDatum
(
LTG_NODE
(
key
)),
...
...
@@ -686,6 +694,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
break
;
case
14
:
case
15
:
query
=
PG_GETARG_LQUERY
(
1
);
if
(
GIST_LEAF
(
entry
))
res
=
DatumGetBool
(
DirectFunctionCall2
(
ltxtq_exec
,
PointerGetDatum
(
LTG_NODE
(
key
)),
...
...
@@ -696,6 +705,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
break
;
case
16
:
case
17
:
query
=
DatumGetPointer
(
PG_DETOAST_DATUM
(
PG_GETARG_DATUM
(
1
)));
if
(
GIST_LEAF
(
entry
))
res
=
DatumGetBool
(
DirectFunctionCall2
(
lt_q_regex
,
PointerGetDatum
(
LTG_NODE
(
key
)),
...
...
@@ -708,5 +718,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
/* internal error */
elog
(
ERROR
,
"unrecognized StrategyNumber: %d"
,
strategy
);
}
PG_FREE_IF_COPY
(
query
,
1
);
PG_RETURN_BOOL
(
res
);
}
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