Skip to content

Commit

Permalink
handling major upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Tanya Gupta <[email protected]>
  • Loading branch information
Tanya Gupta committed Sep 25, 2024
1 parent c7ae7fb commit 1755841
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions contrib/babelfishpg_tsql/src/pltsql_function_probin_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ pltsql_function_probin_writer(CreateFunctionStmt *stmt, Oid languageOid, char **
char *langname;
int probin_len;
Jsonb *jb;
bool dump_restore = false;
const char *babelfish_dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);

if (babelfish_dump_restore &&
strncmp(babelfish_dump_restore, "on", 2) == 0)
dump_restore = true;

langname = get_language_name(languageOid, true);
/* only write probin when language is pltsql */
if (!langname || strcmp(langname, "pltsql") != 0)
return;

/* skip if probin is already set */
if ((*probin_str_p) && (*probin_str_p)[0] == '{')
if ((*probin_str_p) && (*probin_str_p)[0] == '{' && (!dump_restore))
return;

jb = ProbinJsonbBuilder(stmt, probin_str_p);
Expand Down Expand Up @@ -396,6 +402,12 @@ buildTypmodArray(CreateFunctionStmt *stmt, int **typmod_array_p, int *array_len_
ListCell *x;
TypeName *ret = stmt->returnType;
int i = 0;
bool dump_restore = false;
const char *babelfish_dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);

if (babelfish_dump_restore &&
strncmp(babelfish_dump_restore, "on", 2) == 0)
dump_restore = true;

*array_len_p = list_length(stmt->parameters);

Expand All @@ -419,7 +431,7 @@ buildTypmodArray(CreateFunctionStmt *stmt, int **typmod_array_p, int *array_len_
{
(*typmod_array_p)[i] = -1;

if (sql_dialect == SQL_DIALECT_TSQL)
if (sql_dialect == SQL_DIALECT_TSQL || dump_restore)
pltsql_check_or_set_default_typmod(fp->argType, &(*typmod_array_p)[i], false, true);
}
else
Expand All @@ -438,7 +450,7 @@ buildTypmodArray(CreateFunctionStmt *stmt, int **typmod_array_p, int *array_len_
{
(*typmod_array_p)[i] = ptr->val.ival.ival;

if (sql_dialect == SQL_DIALECT_TSQL)
if (sql_dialect == SQL_DIALECT_TSQL || dump_restore)
pltsql_check_or_set_default_typmod(fp->argType, &(*typmod_array_p)[i], false, true);
}
typmod_head = lnext(arg_typmod, typmod_head);
Expand Down Expand Up @@ -470,7 +482,7 @@ buildTypmodArray(CreateFunctionStmt *stmt, int **typmod_array_p, int *array_len_
{
(*typmod_array_p)[i] = ptr->val.ival.ival;

if (sql_dialect == SQL_DIALECT_TSQL)
if (sql_dialect == SQL_DIALECT_TSQL || dump_restore)
pltsql_check_or_set_default_typmod(ret, &(*typmod_array_p)[i], false, true);
}
typmod_head = lnext(ret->typmods, typmod_head);
Expand All @@ -480,7 +492,7 @@ buildTypmodArray(CreateFunctionStmt *stmt, int **typmod_array_p, int *array_len_
{
(*typmod_array_p)[i] = -1;

if (sql_dialect == SQL_DIALECT_TSQL)
if (sql_dialect == SQL_DIALECT_TSQL || dump_restore)
pltsql_check_or_set_default_typmod(ret, &(*typmod_array_p)[i], false, true);
i++;
}
Expand Down

0 comments on commit 1755841

Please sign in to comment.