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
5b5c83f9
Commit
5b5c83f9
authored
Jun 02, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Oracle like currval behaviour.
parent
465047d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
21 deletions
+7
-21
src/backend/commands/sequence.c
src/backend/commands/sequence.c
+7
-21
No files found.
src/backend/commands/sequence.c
View file @
5b5c83f9
...
@@ -204,6 +204,7 @@ nextval (struct varlena * seqin)
...
@@ -204,6 +204,7 @@ nextval (struct varlena * seqin)
/* open and WIntentLock sequence */
/* open and WIntentLock sequence */
elm
=
init_sequence
(
"nextval"
,
seqname
);
elm
=
init_sequence
(
"nextval"
,
seqname
);
pfree
(
seqname
);
if
(
elm
->
last
!=
elm
->
cached
)
/* some numbers were cached */
if
(
elm
->
last
!=
elm
->
cached
)
/* some numbers were cached */
{
{
...
@@ -237,7 +238,7 @@ nextval (struct varlena * seqin)
...
@@ -237,7 +238,7 @@ nextval (struct varlena * seqin)
break
;
/* stop caching */
break
;
/* stop caching */
if
(
seq
->
is_cycled
!=
't'
)
if
(
seq
->
is_cycled
!=
't'
)
elog
(
WARN
,
"%s.nextval: got MAXVALUE (%d)"
,
elog
(
WARN
,
"%s.nextval: got MAXVALUE (%d)"
,
seq
name
,
maxv
);
elm
->
name
,
maxv
);
next
=
minv
;
next
=
minv
;
}
}
else
else
...
@@ -252,7 +253,7 @@ nextval (struct varlena * seqin)
...
@@ -252,7 +253,7 @@ nextval (struct varlena * seqin)
break
;
/* stop caching */
break
;
/* stop caching */
if
(
seq
->
is_cycled
!=
't'
)
if
(
seq
->
is_cycled
!=
't'
)
elog
(
WARN
,
"%s.nextval: got MINVALUE (%d)"
,
elog
(
WARN
,
"%s.nextval: got MINVALUE (%d)"
,
seq
name
,
minv
);
elm
->
name
,
minv
);
next
=
maxv
;
next
=
maxv
;
}
}
else
else
...
@@ -287,33 +288,18 @@ currval (struct varlena * seqin)
...
@@ -287,33 +288,18 @@ currval (struct varlena * seqin)
{
{
char
*
seqname
=
textout
(
seqin
);
char
*
seqname
=
textout
(
seqin
);
SeqTable
elm
;
SeqTable
elm
;
Buffer
buf
;
SequenceTupleForm
seq
;
ItemPointerData
iptr
;
int4
result
;
int4
result
;
/* open and WIntentLock sequence */
/* open and WIntentLock sequence */
elm
=
init_sequence
(
"currval"
,
seqname
);
elm
=
init_sequence
(
"currval"
,
seqname
);
pfree
(
seqname
);
if
(
elm
->
last
!=
elm
->
cached
)
/* some numbers were cached */
if
(
elm
->
increment
==
0
)
/* nextval/read_info were not called */
{
return
(
elm
->
last
);
/* return last returned by nextval */
}
seq
=
read_info
(
"currval"
,
elm
,
&
buf
);
if
(
seq
->
is_called
!=
't'
)
{
{
elog
(
WARN
,
"%s.currval: yet undefined (%s.nextval never called)"
,
elog
(
WARN
,
"%s.currval is not yet defined in this session"
,
elm
->
name
);
seqname
,
seqname
);
}
}
result
=
seq
->
last_value
;
if
(
ReleaseBuffer
(
buf
)
==
STATUS_ERROR
)
result
=
elm
->
last
;
elog
(
WARN
,
"%s.currval: ReleaseBuffer failed"
,
seqname
);
ItemPointerSet
(
&
iptr
,
0
,
FirstOffsetNumber
);
RelationUnsetSingleWLockPage
(
elm
->
rel
,
&
iptr
);
return
(
result
);
return
(
result
);
...
...
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