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
17ac7479
Commit
17ac7479
authored
Nov 18, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put back error test for DECLARE CURSOR outside a transaction block ...
but do it correctly now.
parent
810f2cfa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
src/backend/access/transam/xact.c
src/backend/access/transam/xact.c
+45
-1
src/backend/tcop/pquery.c
src/backend/tcop/pquery.c
+3
-1
src/include/access/xact.h
src/include/access/xact.h
+2
-1
No files found.
src/backend/access/transam/xact.c
View file @
17ac7479
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.13
8 2002/11/13 03:12:05 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.13
9 2002/11/18 01:17:39 tgl
Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
...
...
@@ -1488,6 +1488,50 @@ PreventTransactionChain(void *stmtNode, const char *stmtType)
}
}
/* --------------------------------
* RequireTransactionChain
*
* This routine is to be called by statements that must run inside
* a transaction block, because they have no effects that persist past
* transaction end (and so calling them outside a transaction block
* is presumably an error). DECLARE CURSOR is an example.
*
* If we appear to be running inside a user-defined function, we do not
* issue an error, since the function could issue more commands that make
* use of the current statement's results. Thus this is an inverse for
* PreventTransactionChain.
*
* stmtNode: pointer to parameter block for statement; this is used in
* a very klugy way to determine whether we are inside a function.
* stmtType: statement type name for error messages.
* --------------------------------
*/
void
RequireTransactionChain
(
void
*
stmtNode
,
const
char
*
stmtType
)
{
/*
* xact block already started?
*/
if
(
IsTransactionBlock
())
return
;
/*
* Are we inside a function call? If the statement's parameter block
* was allocated in QueryContext, assume it is an interactive command.
* Otherwise assume it is coming from a function.
*/
if
(
!
MemoryContextContains
(
QueryContext
,
stmtNode
))
return
;
/*
* If we are in autocommit-off mode then it's okay, because this
* statement will itself start a transaction block.
*/
if
(
!
autocommit
&&
!
suppressChain
)
return
;
/* translator: %s represents an SQL statement name */
elog
(
ERROR
,
"%s may only be used in begin/end transaction blocks"
,
stmtType
);
}
/* ----------------------------------------------------------------
* transaction block support
...
...
src/backend/tcop/pquery.c
View file @
17ac7479
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.5
5 2002/09/04 20:31:26 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.5
6 2002/11/18 01:17:39 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -161,6 +161,8 @@ ProcessQuery(Query *parsetree,
/* If binary portal, switch to alternate output format */
if
(
dest
==
Remote
&&
parsetree
->
isBinary
)
dest
=
RemoteInternal
;
/* Check for invalid context (must be in transaction block) */
RequireTransactionChain
((
void
*
)
parsetree
,
"DECLARE CURSOR"
);
}
else
if
(
parsetree
->
into
!=
NULL
)
{
...
...
src/include/access/xact.h
View file @
17ac7479
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: xact.h,v 1.4
7 2002/11/13 03:12:05 momjian
Exp $
* $Id: xact.h,v 1.4
8 2002/11/18 01:17:39 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -115,6 +115,7 @@ extern bool IsTransactionBlock(void);
extern
void
UserAbortTransactionBlock
(
void
);
extern
void
AbortOutOfAnyTransaction
(
void
);
extern
void
PreventTransactionChain
(
void
*
stmtNode
,
const
char
*
stmtType
);
extern
void
RequireTransactionChain
(
void
*
stmtNode
,
const
char
*
stmtType
);
extern
void
RecordTransactionCommit
(
void
);
...
...
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