diff --git a/src/gausskernel/optimizer/commands/functioncmds.cpp b/src/gausskernel/optimizer/commands/functioncmds.cpp index 64e733612..435a7732b 100755 --- a/src/gausskernel/optimizer/commands/functioncmds.cpp +++ b/src/gausskernel/optimizer/commands/functioncmds.cpp @@ -98,6 +98,40 @@ static const int PRO_RETURN_SET_COST = 1000; * validator, so as not to produce a NOTICE and then an ERROR for the same * condition.) */ + static void CheckIsSerialType(TypeName* t) +{ + bool isSerial = false; + /* Check for SERIAL pseudo-types */ + if (t && list_length(t->names) == 1 && t->pct_type == false) { + char* typname = strVal(linitial(t->names)); + + if (strcmp(typname, "smallserial") == 0 || strcmp(typname, "serial2") == 0) { + isSerial = true; + t->names = NIL; + t->typeOid = INT2OID; + } else if (strcmp(typname, "serial") == 0 || strcmp(typname, "serial4") == 0) { + isSerial = true; + t->names = NIL; + t->typeOid = INT4OID; + } else if (strcmp(typname, "bigserial") == 0 || strcmp(typname, "serial8") == 0) { + isSerial = true; + t->names = NIL; + t->typeOid = INT8OID; + } + + if (isSerial && t->arrayBounds != NIL) { + /* + * We have to reject "serial[]" explicitly, because once we've set + * typeid, LookupTypeName won't notice arrayBounds. We don't need any + * special coding for serial(typmod) though. + */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("array of serial is not implemented"))); + } + } +} + static void compute_return_type( TypeName* returnType, Oid languageOid, Oid* prorettype_p, bool* returnsSet_p, bool fenced) { @@ -105,45 +139,13 @@ static void compute_return_type( Type typtup; AclResult aclresult; Oid typowner = InvalidOid; - bool isSerial = false; /* * isalter is true, change the owner of the objects as the owner of the * namespace, if the owner of the namespce has the same name as the namescpe */ bool isalter = false; - /* Check for SERIAL pseudo-types */ - isSerial = false; - if (returnType && list_length(returnType->names) == 1 && returnType->pct_type == false) { - char* typname = strVal(linitial(returnType->names)); - - if (strcmp(typname, "smallserial") == 0 || strcmp(typname, "serial2") == 0) { - isSerial = true; - returnType->names = NIL; - returnType->typeOid = INT2OID; - } else if (strcmp(typname, "serial") == 0 || strcmp(typname, "serial4") == 0) { - isSerial = true; - returnType->names = NIL; - returnType->typeOid = INT4OID; - } else if (strcmp(typname, "bigserial") == 0 || strcmp(typname, "serial8") == 0) { - isSerial = true; - returnType->names = NIL; - returnType->typeOid = INT8OID; - } - - if (isSerial) { - /* - * We have to reject "serial[]" explicitly, because once we've set - * typeid, LookupTypeName won't notice arrayBounds. We don't need any - * special coding for serial(typmod) though. - */ - if (returnType->arrayBounds != NIL) { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array of serial is not implemented"))); - } - } - } + CheckIsSerialType(returnType); typtup = LookupTypeName(NULL, returnType, NULL); /* @@ -257,7 +259,6 @@ static void examine_parameter_list(List* parameters, Oid languageOid, const char int outCount = 0; int varCount = 0; bool have_names = false; - bool isSerial = false; ListCell* x = NULL; int i; ParseState* pstate = NULL; @@ -284,49 +285,7 @@ static void examine_parameter_list(List* parameters, Oid languageOid, const char Type typtup; AclResult aclresult; - /* Check for SERIAL pseudo-types */ - isSerial = false; - if (t && list_length(t->names) == 1 && t->pct_type == false) { - char* typname = strVal(linitial(t->names)); - - if (strcmp(typname, "smallserial") == 0 || strcmp(typname, "serial2") == 0) { - isSerial = true; - t->names = NIL; - t->typeOid = INT2OID; - } else if (strcmp(typname, "serial") == 0 || strcmp(typname, "serial4") == 0) { - isSerial = true; - t->names = NIL; - t->typeOid = INT4OID; - } else if (strcmp(typname, "bigserial") == 0 || strcmp(typname, "serial8") == 0) { - isSerial = true; - t->names = NIL; - t->typeOid = INT8OID; - } - - if (isSerial) { - /* - * We have to reject "serial[]" explicitly, because once we've set - * typeid, LookupTypeName won't notice arrayBounds. We don't need any - * special coding for serial(typmod) though. - */ - if (t->arrayBounds != NIL) { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("array of serial is not implemented"))); - } - } - } - - typtup = LookupTypeName(NULL, t, NULL); - /* - * If the type is relation, then we check - * whether the table is in installation group - */ - if (!in_logic_cluster() && !IsTypeTableInInstallationGroup(typtup)) { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("argument type '%s' must be in installation group", TypeNameToString(t)))); - } + CheckIsSerialType(t); if (typtup) { if (!((Form_pg_type)GETSTRUCT(typtup))->typisdefined) {