diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index cdf2cb5c4ce..6f62a566a2f 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1297,6 +1297,7 @@ init_params(ParseState *pstate, List *options, bool for_identity, ListCell *option; bool reset_max_value = false; bool reset_min_value = false; + Oid usr_type_id = 0; *need_seq_rewrite = false; *owned_by = NIL; @@ -1390,6 +1391,8 @@ init_params(ParseState *pstate, List *options, bool for_identity, */ if (isInit) seqdataform->log_cnt = 0; + + /* AS type */ if (as_type != NULL) @@ -1401,14 +1404,15 @@ init_params(ParseState *pstate, List *options, bool for_identity, */ Oid newtypid = 0; + if (pltsql_sequence_datatype_hook) - (* pltsql_sequence_datatype_hook) (pstate, + (*pltsql_sequence_datatype_hook) (pstate, &newtypid, for_identity, as_type, &max_value, - &min_value); + &min_value,&usr_type_id); if(!newtypid) newtypid = typenameTypeId(pstate,defGetTypeName(as_type)); @@ -1619,9 +1623,13 @@ init_params(ParseState *pstate, List *options, bool for_identity, } if(pltsql_sequence_validate_increment_hook) + { (* pltsql_sequence_validate_increment_hook) (seqform->seqincrement, seqform->seqmax, - seqform->seqmin); + seqform->seqmin + ); + seqform->seqtypid = usr_type_id; + } } /* diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h index 91349845c45..335c55a35d4 100644 --- a/src/include/commands/sequence.h +++ b/src/include/commands/sequence.h @@ -34,7 +34,7 @@ typedef void (*pltsql_sequence_datatype_hook_type) (ParseState *pstate, bool for_identity, DefElem *as_type, DefElem **max_value, - DefElem **min_value); + DefElem **min_value,Oid *usr_type_id); extern PGDLLIMPORT pltsql_sequence_datatype_hook_type pltsql_sequence_datatype_hook; /* Sequence nextval hook */