|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.108 2004/01/10 23:28:44 neilc Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.109 2004/04/06 16:39:30 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -315,32 +315,17 @@ AlterSequence(AlterSeqStmt *stmt)
|
315 | 315 | seq=read_info(elm,seqrel,&buf);
|
316 | 316 | page=BufferGetPage(buf);
|
317 | 317 |
|
318 |
| -/* copy old values of options */ |
319 |
| -new.increment_by=seq->increment_by; |
320 |
| -new.max_value=seq->max_value; |
321 |
| -new.min_value=seq->min_value; |
322 |
| -new.cache_value=seq->cache_value; |
323 |
| -new.is_cycled=seq->is_cycled; |
324 |
| -new.last_value=seq->last_value; |
| 318 | +/* Copy old values of options into workspace */ |
| 319 | +memcpy(&new,seq,sizeof(FormData_pg_sequence)); |
325 | 320 |
|
326 | 321 | /* Check and set new values */
|
327 | 322 | init_params(stmt->options,&new, false);
|
328 | 323 |
|
329 | 324 | /* Now okay to update the on-disk tuple */
|
330 |
| -seq->increment_by=new.increment_by; |
331 |
| -seq->max_value=new.max_value; |
332 |
| -seq->min_value=new.min_value; |
333 |
| -seq->cache_value=new.cache_value; |
334 |
| -seq->is_cycled=new.is_cycled; |
335 |
| -if (seq->last_value!=new.last_value) |
336 |
| -{ |
337 |
| -seq->last_value=new.last_value; |
338 |
| -seq->is_called= false; |
339 |
| -seq->log_cnt=1; |
340 |
| -} |
| 325 | +memcpy(seq,&new,sizeof(FormData_pg_sequence)); |
341 | 326 |
|
342 |
| -/*save info inlocal cache */ |
343 |
| -elm->last=new.last_value;/* last returned number */ |
| 327 | +/*Clearlocal cache so that we don't think we have cached numbers */ |
| 328 | +elm->last=new.last_value;/* last returned number */ |
344 | 329 | elm->cached=new.last_value;/* last cached number (forget
|
345 | 330 | * cached values) */
|
346 | 331 |
|
@@ -1008,13 +993,19 @@ init_params(List *options, Form_pg_sequence new, bool isInit)
|
1008 | 993 |
|
1009 | 994 | /* START WITH */
|
1010 | 995 | if (last_value!=NULL)
|
| 996 | +{ |
1011 | 997 | new->last_value=defGetInt64(last_value);
|
| 998 | +new->is_called= false; |
| 999 | +new->log_cnt=1; |
| 1000 | +} |
1012 | 1001 | elseif (isInit)
|
1013 | 1002 | {
|
1014 | 1003 | if (new->increment_by>0)
|
1015 | 1004 | new->last_value=new->min_value;/* ascending seq */
|
1016 | 1005 | else
|
1017 | 1006 | new->last_value=new->max_value;/* descending seq */
|
| 1007 | +new->is_called= false; |
| 1008 | +new->log_cnt=1; |
1018 | 1009 | }
|
1019 | 1010 |
|
1020 | 1011 | /* crosscheck */
|
|