* init_params: process the options list of CREATE or ALTER SEQUENCE, and * store the values into appropriate fields of seqform, for changes that go * into the pg_sequence catalog, and fields of seqdataform for changes to the * sequence relation itself. Set *need_seq_rewrite to true if we changed any * parameters that require rewriting the sequence's relation (interesting for * ALTER SEQUENCE
| 1417 | * break pg_upgrade by causing unwanted changes in the sequence's relfilenode. |
| 1418 | */ |
| 1419 | static void |
| 1420 | init_params(ParseState *pstate, List *options, bool for_identity, |
| 1421 | bool isInit, |
| 1422 | Form_pg_sequence seqform, |
| 1423 | Form_pg_sequence_data seqdataform, |
| 1424 | bool *need_seq_rewrite, |
| 1425 | List **owned_by) |
| 1426 | { |
| 1427 | DefElem *as_type = NULL; |
| 1428 | DefElem *start_value = NULL; |
| 1429 | DefElem *restart_value = NULL; |
| 1430 | DefElem *increment_by = NULL; |
| 1431 | DefElem *max_value = NULL; |
| 1432 | DefElem *min_value = NULL; |
| 1433 | DefElem *cache_value = NULL; |
| 1434 | DefElem *is_cycled = NULL; |
| 1435 | ListCell *option; |
| 1436 | bool reset_max_value = false; |
| 1437 | bool reset_min_value = false; |
| 1438 | |
| 1439 | *need_seq_rewrite = false; |
| 1440 | *owned_by = NIL; |
| 1441 | |
| 1442 | foreach(option, options) |
| 1443 | { |
| 1444 | DefElem *defel = (DefElem *) lfirst(option); |
| 1445 | |
| 1446 | if (strcmp(defel->defname, "as") == 0) |
| 1447 | { |
| 1448 | if (as_type) |
| 1449 | ereport(ERROR, |
| 1450 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 1451 | errmsg("conflicting or redundant options"), |
| 1452 | parser_errposition(pstate, defel->location))); |
| 1453 | as_type = defel; |
| 1454 | *need_seq_rewrite = true; |
| 1455 | } |
| 1456 | else if (strcmp(defel->defname, "increment") == 0) |
| 1457 | { |
| 1458 | if (increment_by) |
| 1459 | ereport(ERROR, |
| 1460 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 1461 | errmsg("conflicting or redundant options"), |
| 1462 | parser_errposition(pstate, defel->location))); |
| 1463 | increment_by = defel; |
| 1464 | *need_seq_rewrite = true; |
| 1465 | } |
| 1466 | else if (strcmp(defel->defname, "start") == 0) |
| 1467 | { |
| 1468 | if (start_value) |
| 1469 | ereport(ERROR, |
| 1470 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 1471 | errmsg("conflicting or redundant options"), |
| 1472 | parser_errposition(pstate, defel->location))); |
| 1473 | start_value = defel; |
| 1474 | *need_seq_rewrite = true; |
| 1475 | } |
| 1476 | else if (strcmp(defel->defname, "restart") == 0) |
no test coverage detected