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
01a89482
Commit
01a89482
authored
Sep 30, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trigger programming guide.
Description of data changes visibility added.
parent
da707e42
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
360 additions
and
1 deletion
+360
-1
doc/spi.txt
doc/spi.txt
+63
-1
doc/trigger.txt
doc/trigger.txt
+297
-0
No files found.
doc/spi.txt
View file @
01a89482
...
...
@@ -71,7 +71,8 @@ int SPI_finish(void)
with this - it means that nothing was made by SPI manager.
NOTE! SPI_finish() MUST be called by connected procedure or you may get
unpredictable results!
unpredictable results! But you are able to don't call SPI_finish() if you
abort transaction (via elog(WARN)).
int SPI_exec(char *query, int tcount)
...
...
@@ -354,6 +355,27 @@ allocate memory for this in upper context!
this query is done!
Data changes visibility
PostgreSQL data changes visibility rule: during query execution data
changes made by query itself (via SQL-function, SPI-function, triggers)
are invisible to the query scan.
For example, in query
INSERT INTO a SELECT * FROM a
tuples inserted are invisible for SELECT' scan.
But also note that
changes made by query Q are visible by queries which are started after
query Q, no matter - are they started inside Q (during execution of Q) or
after Q is done.
Last example of usage SPI function below demonstrates visibility rule.
Examples
There are complex examples in contrib/spi and in
...
...
@@ -446,3 +468,43 @@ execq
-----
3 <<< 10 is max value only, 3 is real # of tuples
(1 row)
vac=> delete from a;
DELETE 3
vac=> insert into a values (execq('select * from a', 0) + 1);
INSERT 167712 1
vac=> select * from a;
x
-
1 <<< no tuples in a (0) + 1
(1 row)
vac=> insert into a values (execq('select * from a', 0) + 1);
NOTICE:EXECQ: 0
INSERT 167713 1
vac=> select * from a;
x
-
1
2 <<< there was single tuple in a + 1
(2 rows)
-- This demonstrates data changes visibility rule:
vac=> insert into a select execq('select * from a', 0) * x from a;
NOTICE:EXECQ: 1
NOTICE:EXECQ: 2
NOTICE:EXECQ: 1
NOTICE:EXECQ: 2
NOTICE:EXECQ: 2
INSERT 0 2
vac=> select * from a;
x
-
1
2
2 <<< 2 tuples * 1 (x in first tuple)
6 <<< 3 tuples (2 + 1 just inserted) * 2 (x in second tuple)
(4 rows) ^^^^^^^^
tuples visible to execq() in different invocations
doc/trigger.txt
0 → 100644
View file @
01a89482
This diff is collapsed.
Click to expand it.
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