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
6fec2160
Commit
6fec2160
authored
Oct 11, 2000
by
Philip Warner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new SQL function setval(seq,val,bool) to restore is_called as well as value
(will be used in a future pg_dump).
parent
8e72a878
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
7 deletions
+32
-7
src/backend/commands/sequence.c
src/backend/commands/sequence.c
+28
-6
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+3
-1
src/include/commands/sequence.h
src/include/commands/sequence.h
+1
-0
No files found.
src/backend/commands/sequence.c
View file @
6fec2160
...
...
@@ -61,6 +61,7 @@ static SeqTable init_sequence(char *caller, char *name);
static
Form_pg_sequence
read_info
(
char
*
caller
,
SeqTable
elm
,
Buffer
*
buf
);
static
void
init_params
(
CreateSeqStmt
*
seq
,
Form_pg_sequence
new
);
static
int
get_param
(
DefElem
*
def
);
static
void
do_setval
(
char
*
seqname
,
int32
next
,
char
iscalled
);
/*
* DefineSequence
...
...
@@ -317,12 +318,9 @@ currval(PG_FUNCTION_ARGS)
PG_RETURN_INT32
(
result
);
}
Datum
setval
(
PG_FUNCTION_ARGS
)
static
void
do_setval
(
char
*
seqname
,
int32
next
,
bool
iscalled
)
{
text
*
seqin
=
PG_GETARG_TEXT_P
(
0
);
int32
next
=
PG_GETARG_INT32
(
1
);
char
*
seqname
=
get_seq_name
(
seqin
);
SeqTable
elm
;
Buffer
buf
;
Form_pg_sequence
seq
;
...
...
@@ -356,7 +354,7 @@ setval(PG_FUNCTION_ARGS)
/* save info in sequence relation */
seq
->
last_value
=
next
;
/* last fetched number */
seq
->
is_called
=
't
'
;
seq
->
is_called
=
iscalled
?
't'
:
'f
'
;
LockBuffer
(
buf
,
BUFFER_LOCK_UNLOCK
);
...
...
@@ -365,6 +363,30 @@ setval(PG_FUNCTION_ARGS)
pfree
(
seqname
);
}
Datum
setval
(
PG_FUNCTION_ARGS
)
{
text
*
seqin
=
PG_GETARG_TEXT_P
(
0
);
int32
next
=
PG_GETARG_INT32
(
1
);
char
*
seqname
=
get_seq_name
(
seqin
);
do_setval
(
seqname
,
next
,
true
);
PG_RETURN_INT32
(
next
);
}
Datum
setval_and_iscalled
(
PG_FUNCTION_ARGS
)
{
text
*
seqin
=
PG_GETARG_TEXT_P
(
0
);
int32
next
=
PG_GETARG_INT32
(
1
);
bool
iscalled
=
PG_GETARG_BOOL
(
2
);
char
*
seqname
=
get_seq_name
(
seqin
);
do_setval
(
seqname
,
next
,
iscalled
);
PG_RETURN_INT32
(
next
);
}
...
...
src/include/catalog/pg_proc.h
View file @
6fec2160
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_proc.h,v 1.16
8 2000/09/25 12:58:47 momjian
Exp $
* $Id: pg_proc.h,v 1.16
9 2000/10/11 15:31:13 pjw
Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
...
...
@@ -1978,6 +1978,8 @@ DATA(insert OID = 1575 ( currval PGUID 12 f t f t 1 f 23 "25" 100 0 0 100 cur
DESCR
(
"sequence current value"
);
DATA
(
insert
OID
=
1576
(
setval
PGUID
12
f
t
f
t
2
f
23
"25 23"
100
0
0
100
setval
-
));
DESCR
(
"set sequence value"
);
DATA
(
insert
OID
=
1765
(
setval
PGUID
12
f
t
f
t
3
f
23
"25 23 16"
100
0
0
100
setval_and_iscalled
-
));
DESCR
(
"set sequence value and iscalled status"
);
DATA
(
insert
OID
=
1579
(
varbit_in
PGUID
12
f
t
t
t
1
f
1562
"0"
100
0
0
100
varbit_in
-
));
DESCR
(
"(internal)"
);
...
...
src/include/commands/sequence.h
View file @
6fec2160
...
...
@@ -30,6 +30,7 @@
extern
Datum
nextval
(
PG_FUNCTION_ARGS
);
extern
Datum
currval
(
PG_FUNCTION_ARGS
);
extern
Datum
setval
(
PG_FUNCTION_ARGS
);
extern
Datum
setval_and_iscalled
(
PG_FUNCTION_ARGS
);
extern
void
DefineSequence
(
CreateSeqStmt
*
stmt
);
extern
void
CloseSequences
(
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