Skip to content

Commit

Permalink
Getting user_type_id for sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Prasad committed Oct 19, 2023
1 parent 2d7aaea commit 099ae9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/backend/commands/sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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));

Expand Down Expand Up @@ -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;
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/include/commands/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 099ae9a

Please sign in to comment.