Datum
seqam_local_reloptions(PG_FUNCTION_ARGS)
{
- Datum reloptions = PG_GETARG_DATUM(0);
- bool validate = PG_GETARG_BOOL(1);
- bytea *result;
+ Datum reloptions = PG_GETARG_DATUM(0);
+ bool validate = PG_GETARG_BOOL(1);
+ bytea *result;
result = default_reloptions(reloptions, validate, RELOPT_KIND_SEQUENCE);
if (result)
Datum
seqam_local_init(PG_FUNCTION_ARGS)
{
- Oid seqrelid = PG_GETARG_OID(0);
- List *seqoptions = (List *) PG_GETARG_POINTER(1);
- Datum *values = (Datum *) PG_GETARG_POINTER(3);
- bool *nulls = (bool *) PG_GETARG_POINTER(4);
- bool found_restart;
- int64 start_value,
- last_value,
- min_value,
- max_value;
+ Oid seqrelid = PG_GETARG_OID(0);
+ List *seqoptions = (List *) PG_GETARG_POINTER(1);
+ Datum *values = (Datum *) PG_GETARG_POINTER(3);
+ bool *nulls = (bool *) PG_GETARG_POINTER(4);
+ bool found_restart;
+ int64 start_value,
+ last_value,
+ min_value,
+ max_value;
FormLocalSequence *localseq;
/* Get the new value to use as starting point. */
seqam_local_alloc(PG_FUNCTION_ARGS)
{
Relation seqrel = (Relation) PG_GETARG_POINTER(0);
- SequenceHandle *seqh = (SequenceHandle*) PG_GETARG_POINTER(1);
+ SequenceHandle *seqh = (SequenceHandle *) PG_GETARG_POINTER(1);
int64 nrequested = PG_GETARG_INT64(2);
int64 *last = (int64 *) PG_GETARG_POINTER(3);
FormData_pg_sequence *seq;
/* Fetch as many values as was requested by backend. */
if (rescnt < nrequested)
rescnt += sequence_increment(seqrel, &next, nrequested-rescnt, minv,
- maxv, incby, is_cycled, false);
+ maxv, incby, is_cycled, false);
/* Last value available for calling backend. */
*last = next;
Datum
seqam_local_setval(PG_FUNCTION_ARGS)
{
- SequenceHandle *seqh = (SequenceHandle*) PG_GETARG_POINTER(1);
- int64 next = PG_GETARG_INT64(2);
- FormData_pg_sequence *seq;
+ SequenceHandle *seqh = (SequenceHandle *) PG_GETARG_POINTER(1);
+ int64 next = PG_GETARG_INT64(2);
+ FormData_pg_sequence *seq;
FormLocalSequence *localseq;
seq = (FormData_pg_sequence *) GETSTRUCT(sequence_read_tuple(seqh));
Datum
seqam_local_get_state(PG_FUNCTION_ARGS)
{
- SequenceHandle *seqh = (SequenceHandle *) PG_GETARG_POINTER(1);
- char ***out_keys = (char ***) PG_GETARG_POINTER(2);
- char ***out_values = (char ***) PG_GETARG_POINTER(3);
- char **keys;
- char **values;
- FormData_pg_sequence *seq;
+ SequenceHandle *seqh = (SequenceHandle *) PG_GETARG_POINTER(1);
+ char ***out_keys = (char ***) PG_GETARG_POINTER(2);
+ char ***out_values = (char ***) PG_GETARG_POINTER(3);
+ char **keys;
+ char **values;
+ FormData_pg_sequence *seq;
seq = (FormData_pg_sequence *) GETSTRUCT(sequence_read_tuple(seqh));
/*
* seqam_local_set_state()
*
- * Restore previously dumpred state of local sequence (used by pg_dump)
+ * Restore previously dumped state of local sequence (used by pg_dump)
*/
Datum
seqam_local_set_state(PG_FUNCTION_ARGS)
{
- SequenceHandle *seqh = (SequenceHandle*) PG_GETARG_POINTER(1);
- char **keys = (char **) PG_GETARG_POINTER(2);
- char **values = (char **) PG_GETARG_POINTER(3);
- int count = PG_GETARG_INT32(4);
- FormData_pg_sequence *seq;
- int i;
+ SequenceHandle *seqh = (SequenceHandle *) PG_GETARG_POINTER(1);
+ char **keys = (char **) PG_GETARG_POINTER(2);
+ char **values = (char **) PG_GETARG_POINTER(3);
+ int count = PG_GETARG_INT32(4);
+ FormData_pg_sequence *seq;
+ int i;
seq = (FormData_pg_sequence *) GETSTRUCT(sequence_read_tuple(seqh));
Oid relid = PG_GETARG_OID(0);
int64 next = PG_GETARG_INT64(1);
bool iscalled = PG_GETARG_BOOL(2);
- char *keys[2] = {"last_value", "is_called"};
+ char *keys[2];
char *values[2];
SeqTable elm;
Relation seqrel;
errmsg("the setval(oid, bigint, bool) function can only be called for \"local\" sequences")));
/* Convert the data into 'local' sequence dump format and call restore API. */
+ keys[0] = "last_value";
values[0] = DatumGetCString(DirectFunctionCall1(int8out,
Int64GetDatum(next)));
+ keys[1] = "is_called";
values[1] = DatumGetCString(DirectFunctionCall1(boolout,
BoolGetDatum(iscalled)));
seqam_set_state(seqh.rel, &seqh, keys, values, 2);
Form_pg_sequence seq_form;
if (seqh->tup.t_data != NULL)
- {
return &seqh->tup;
- }
seqh->buf = buf = ReadBuffer(seqh->rel, 0);
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
}
/*
- * Process an OWNED BY param for CREATE/ALTER SEQUENCE
+ * Process an OWNED BY option for CREATE/ALTER SEQUENCE
*
* Ownership permissions on the sequence are already checked,
* but if we are establishing a new owned-by dependency, we must
nnames = list_length(owned_by);
Assert(nnames > 0);
- if (nnames == 1) {
+ if (nnames == 1)
+ {
/* Must be OWNED BY NONE */
if (strcmp(strVal(linitial(owned_by)), "none") != 0)
ereport(ERROR,
pfree(localpage);
}
-
/*
* Flush cached sequence information.
*/
sequence_increment(Relation seqrel, int64 *value, int64 incnum, int64 minv,
int64 maxv, int64 incby, bool is_cycled, bool report_errors)
{
- int64 next = *value;
- int64 rescnt = 0;
+ int64 next = *value;
+ int64 rescnt = 0;
while (incnum)
{
(maxv < 0 && next + incby > maxv))
{
/*
- * We were asked to not report errors, return without incrementing
- * and let the caller handle it.
+ * We were asked to not report errors, return without
+ * incrementing and let the caller handle it.
*/
if (!report_errors)
return rescnt;