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
be3aa30d
Commit
be3aa30d
authored
Jul 09, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inadequate error checking: you can't assume that fcinfo->resultinfo
is a ReturnSetInfo unless you've tested it with IsA.
parent
40d091b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
41 deletions
+45
-41
contrib/tablefunc/tablefunc.c
contrib/tablefunc/tablefunc.c
+21
-19
contrib/xml2/xpath.c
contrib/xml2/xpath.c
+24
-22
No files found.
contrib/tablefunc/tablefunc.c
View file @
be3aa30d
...
...
@@ -687,9 +687,13 @@ crosstab_hash(PG_FUNCTION_ARGS)
int
num_categories
;
/* check to see if caller supports us returning a tuplestore */
if
(
!
rsinfo
||
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
if
(
rsinfo
==
NULL
||
!
IsA
(
rsinfo
,
ReturnSetInfo
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"set-valued function called in context that cannot accept a set"
)));
if
(
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"materialize mode required, but it is not "
\
"allowed in this context"
)));
...
...
@@ -1049,9 +1053,13 @@ connectby_text(PG_FUNCTION_ARGS)
MemoryContext
oldcontext
;
/* check to see if caller supports us returning a tuplestore */
if
(
!
rsinfo
||
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
if
(
rsinfo
==
NULL
||
!
IsA
(
rsinfo
,
ReturnSetInfo
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"set-valued function called in context that cannot accept a set"
)));
if
(
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"materialize mode required, but it is not "
\
"allowed in this context"
)));
...
...
@@ -1076,13 +1084,6 @@ connectby_text(PG_FUNCTION_ARGS)
/* OK, use it then */
attinmeta
=
TupleDescGetAttInMetadata
(
tupdesc
);
/* check to see if caller supports us returning a tuplestore */
if
(
!
rsinfo
||
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"materialize mode required, but it is not "
\
"allowed in this context"
)));
/* OK, go to work */
rsinfo
->
returnMode
=
SFRM_Materialize
;
rsinfo
->
setResult
=
connectby
(
relname
,
...
...
@@ -1131,9 +1132,15 @@ connectby_text_serial(PG_FUNCTION_ARGS)
MemoryContext
oldcontext
;
/* check to see if caller supports us returning a tuplestore */
if
(
!
rsinfo
||
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
elog
(
ERROR
,
"connectby: materialize mode required, but it is not "
"allowed in this context"
);
if
(
rsinfo
==
NULL
||
!
IsA
(
rsinfo
,
ReturnSetInfo
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"set-valued function called in context that cannot accept a set"
)));
if
(
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"materialize mode required, but it is not "
\
"allowed in this context"
)));
if
(
fcinfo
->
nargs
==
7
)
{
...
...
@@ -1156,11 +1163,6 @@ connectby_text_serial(PG_FUNCTION_ARGS)
/* OK, use it then */
attinmeta
=
TupleDescGetAttInMetadata
(
tupdesc
);
/* check to see if caller supports us returning a tuplestore */
if
(
!
rsinfo
->
allowedModes
&
SFRM_Materialize
)
elog
(
ERROR
,
"connectby requires Materialize mode, but it is not "
"allowed in this context"
);
/* OK, go to work */
rsinfo
->
returnMode
=
SFRM_Materialize
;
rsinfo
->
setResult
=
connectby
(
relname
,
...
...
contrib/xml2/xpath.c
View file @
be3aa30d
...
...
@@ -669,23 +669,36 @@ xpath_table(PG_FUNCTION_ARGS)
StringInfo
querysql
;
/* We only have a valid tuple description in table function mode */
/* We only have a valid tuple description in table function mode */
if
(
rsinfo
==
NULL
||
!
IsA
(
rsinfo
,
ReturnSetInfo
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"set-valued function called in context that cannot accept a set"
)));
if
(
rsinfo
->
expectedDesc
==
NULL
)
{
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"xpath_table must be called as a table function"
)));
}
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"xpath_table must be called as a table function"
)));
/* The tuplestore must exist in a higher context than
* this function call (per_query_ctx is used) */
/*
* We want to materialise because it means that we don't have to carry
* libxml2 parser state between invocations of this function
*/
if
(
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"xpath_table requires Materialize mode, but it is not "
"allowed in this context"
)));
/* The tuplestore must exist in a higher context than
* this function call (per_query_ctx is used)
*/
per_query_ctx
=
rsinfo
->
econtext
->
ecxt_per_query_memory
;
oldcontext
=
MemoryContextSwitchTo
(
per_query_ctx
);
/* Create the tuplestore - work_mem is the max in-memory size before a
* file is created on disk to hold it.
*/
/* Create the tuplestore - work_mem is the max in-memory size before a
* file is created on disk to hold it.
*/
tupstore
=
tuplestore_begin_heap
(
true
,
false
,
work_mem
);
MemoryContextSwitchTo
(
oldcontext
);
...
...
@@ -703,17 +716,6 @@ xpath_table(PG_FUNCTION_ARGS)
attinmeta
=
TupleDescGetAttInMetadata
(
ret_tupdesc
);
/*
* We want to materialise because it means that we don't have to carry
* libxml2 parser state between invocations of this function
*/
/* check to see if caller supports us returning a tuplestore */
if
(
!
rsinfo
||
!
(
rsinfo
->
allowedModes
&
SFRM_Materialize
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_SYNTAX_ERROR
),
errmsg
(
"xpath_table requires Materialize mode, but it is not "
"allowed in this context"
)));
/* Set return mode and allocate value space. */
rsinfo
->
returnMode
=
SFRM_Materialize
;
rsinfo
->
setDesc
=
ret_tupdesc
;
...
...
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