diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index c0a75de..1d3867b *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** SELECT pg_type_is_visible('myschema.widg *** 14854,14859 **** --- 14854,14875 ---- collation for + + to_regclass + + + + to_regproc + + + + to_regoper + + + + to_regtype + + lists functions that extract information from the system catalogs. *************** SELECT pg_type_is_visible('myschema.widg *** 15024,15029 **** --- 15040,15065 ---- text get the collation of the argument + + to_regclass(table_name) + regclass + get the table oid + + + to_regproc(func_name) + regproc + get the function oid + + + to_regoper(operator_name) + regoper + get the operator oid + + + to_regtype(type_name) + regtype + get the type oid + *************** SELECT collation for ('foo' COLLATE "de_ *** 15189,15194 **** --- 15225,15236 ---- is not of a collatable data type, then an error is raised. + + to_regclass, to_regproc, to_regoper and to_regtype are similar to + regclass, regproc, regoper and regtype except that if the requested object + is not found, returns InvalidOid, rather than raises an error. + + col_description diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c new file mode 100644 index db8cb82..e4aa1eb *** a/src/backend/access/common/tupdesc.c --- b/src/backend/access/common/tupdesc.c *************** BuildDescForRelation(List *schema) *** 617,623 **** attnum++; attname = entry->colname; ! typenameTypeIdAndMod(NULL, entry->typeName, &atttypid, &atttypmod); aclresult = pg_type_aclcheck(atttypid, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) --- 617,623 ---- attnum++; attname = entry->colname; ! typenameTypeIdAndMod(NULL, entry->typeName, &atttypid, &atttypmod, false); aclresult = pg_type_aclcheck(atttypid, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c new file mode 100644 index 6c2a5d2..0253610 *** a/src/backend/catalog/namespace.c --- b/src/backend/catalog/namespace.c *************** OpernameGetOprid(List *names, Oid oprlef *** 1556,1562 **** * will be InvalidOid for a prefix or postfix oprkind. nargs is 2, too. */ FuncCandidateList ! OpernameGetCandidates(List *names, char oprkind) { FuncCandidateList resultList = NULL; char *resultSpace = NULL; --- 1556,1562 ---- * will be InvalidOid for a prefix or postfix oprkind. nargs is 2, too. */ FuncCandidateList ! OpernameGetCandidates(List *names, char oprkind, bool missing_ok) { FuncCandidateList resultList = NULL; char *resultSpace = NULL; *************** OpernameGetCandidates(List *names, char *** 1573,1579 **** if (schemaname) { /* use exact schema given */ ! namespaceId = LookupExplicitNamespace(schemaname, false); } else { --- 1573,1581 ---- if (schemaname) { /* use exact schema given */ ! namespaceId = LookupExplicitNamespace(schemaname, missing_ok); ! if (!OidIsValid(namespaceId)) ! return NULL; } else { diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c new file mode 100644 index 08b037e..adc2680 *** a/src/backend/commands/tablecmds.c --- b/src/backend/commands/tablecmds.c *************** MergeAttributes(List *schema, List *supe *** 1566,1572 **** (errmsg("merging multiple inherited definitions of column \"%s\"", attributeName))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); ! typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod); if (defTypeId != attribute->atttypid || deftypmod != attribute->atttypmod) ereport(ERROR, --- 1566,1572 ---- (errmsg("merging multiple inherited definitions of column \"%s\"", attributeName))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); ! typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod, false); if (defTypeId != attribute->atttypid || deftypmod != attribute->atttypmod) ereport(ERROR, *************** MergeAttributes(List *schema, List *supe *** 1775,1782 **** (errmsg("merging column \"%s\" with inherited definition", attributeName))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); ! typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod); ! typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod); if (defTypeId != newTypeId || deftypmod != newtypmod) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), --- 1775,1782 ---- (errmsg("merging column \"%s\" with inherited definition", attributeName))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); ! typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod, false); ! typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod, false); if (defTypeId != newTypeId || deftypmod != newtypmod) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), *************** ATExecAddColumn(List **wqueue, AlteredTa *** 4463,4469 **** Oid ccollid; /* Child column must match on type, typmod, and collation */ ! typenameTypeIdAndMod(NULL, colDef->typeName, &ctypeId, &ctypmod); if (ctypeId != childatt->atttypid || ctypmod != childatt->atttypmod) ereport(ERROR, --- 4463,4469 ---- Oid ccollid; /* Child column must match on type, typmod, and collation */ ! typenameTypeIdAndMod(NULL, colDef->typeName, &ctypeId, &ctypmod, false); if (ctypeId != childatt->atttypid || ctypmod != childatt->atttypmod) ereport(ERROR, *************** ATPrepAlterColumnType(List **wqueue, *** 7442,7448 **** colName))); /* Look up the target type */ ! typenameTypeIdAndMod(NULL, typeName, &targettype, &targettypmod); aclresult = pg_type_aclcheck(targettype, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) --- 7442,7448 ---- colName))); /* Look up the target type */ ! typenameTypeIdAndMod(NULL, typeName, &targettype, &targettypmod, false); aclresult = pg_type_aclcheck(targettype, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c new file mode 100644 index 81c9338..a94dc02 *** a/src/backend/parser/parse_expr.c --- b/src/backend/parser/parse_expr.c *************** transformExprRecurse(ParseState *pstate, *** 184,190 **** int32 targetTypmod; typenameTypeIdAndMod(pstate, tc->typeName, ! &targetType, &targetTypmod); /* * If target is a domain over array, work with the base --- 184,190 ---- int32 targetTypmod; typenameTypeIdAndMod(pstate, tc->typeName, ! &targetType, &targetTypmod, false); /* * If target is a domain over array, work with the base *************** transformXmlSerialize(ParseState *pstate *** 2052,2058 **** XMLOID, "XMLSERIALIZE")); ! typenameTypeIdAndMod(pstate, xs->typeName, &targetType, &targetTypmod); xexpr->xmloption = xs->xmloption; xexpr->location = xs->location; --- 2052,2058 ---- XMLOID, "XMLSERIALIZE")); ! typenameTypeIdAndMod(pstate, xs->typeName, &targetType, &targetTypmod, false); xexpr->xmloption = xs->xmloption; xexpr->location = xs->location; *************** transformTypeCast(ParseState *pstate, Ty *** 2222,2228 **** int32 targetTypmod; int location; ! typenameTypeIdAndMod(pstate, tc->typeName, &targetType, &targetTypmod); if (inputType == InvalidOid) return expr; /* do nothing if NULL input */ --- 2222,2228 ---- int32 targetTypmod; int location; ! typenameTypeIdAndMod(pstate, tc->typeName, &targetType, &targetTypmod, false); if (inputType == InvalidOid) return expr; /* do nothing if NULL input */ diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c new file mode 100644 index 99dbd30..a2b712d *** a/src/backend/parser/parse_oper.c --- b/src/backend/parser/parse_oper.c *************** oper(ParseState *pstate, List *opname, O *** 407,413 **** FuncCandidateList clist; /* Get binary operators of given name */ ! clist = OpernameGetCandidates(opname, 'b'); /* No operators found? Then fail... */ if (clist != NULL) --- 407,413 ---- FuncCandidateList clist; /* Get binary operators of given name */ ! clist = OpernameGetCandidates(opname, 'b', false); /* No operators found? Then fail... */ if (clist != NULL) *************** right_oper(ParseState *pstate, List *op, *** 553,559 **** FuncCandidateList clist; /* Get postfix operators of given name */ ! clist = OpernameGetCandidates(op, 'r'); /* No operators found? Then fail... */ if (clist != NULL) --- 553,559 ---- FuncCandidateList clist; /* Get postfix operators of given name */ ! clist = OpernameGetCandidates(op, 'r', false); /* No operators found? Then fail... */ if (clist != NULL) *************** left_oper(ParseState *pstate, List *op, *** 631,637 **** FuncCandidateList clist; /* Get prefix operators of given name */ ! clist = OpernameGetCandidates(op, 'l'); /* No operators found? Then fail... */ if (clist != NULL) --- 631,637 ---- FuncCandidateList clist; /* Get prefix operators of given name */ ! clist = OpernameGetCandidates(op, 'l', false); /* No operators found? Then fail... */ if (clist != NULL) diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c new file mode 100644 index 8760952..51c13b8 *** a/src/backend/parser/parse_relation.c --- b/src/backend/parser/parse_relation.c *************** addRangeTableEntryForFunction(ParseState *** 1340,1346 **** attrname), parser_errposition(pstate, n->location))); typenameTypeIdAndMod(pstate, n->typeName, ! &attrtype, &attrtypmod); attrcollation = GetColumnDefCollation(pstate, n, attrtype); TupleDescInitEntry(tupdesc, (AttrNumber) i, --- 1340,1346 ---- attrname), parser_errposition(pstate, n->location))); typenameTypeIdAndMod(pstate, n->typeName, ! &attrtype, &attrtypmod, false); attrcollation = GetColumnDefCollation(pstate, n, attrtype); TupleDescInitEntry(tupdesc, (AttrNumber) i, diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c new file mode 100644 index b329dfb..4ccc82b *** a/src/backend/parser/parse_type.c --- b/src/backend/parser/parse_type.c *************** *** 29,35 **** static int32 typenameTypeMod(ParseState *pstate, const TypeName *typeName, ! Type typ); /* --- 29,35 ---- static int32 typenameTypeMod(ParseState *pstate, const TypeName *typeName, ! Type typ); /* *************** typenameTypeId(ParseState *pstate, const *** 287,299 **** */ void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, ! Oid *typeid_p, int32 *typmod_p) { Type tup; ! tup = typenameType(pstate, typeName, typmod_p); ! *typeid_p = HeapTupleGetOid(tup); ! ReleaseSysCache(tup); } /* --- 287,314 ---- */ void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, ! Oid *typeid_p, int32 *typmod_p, ! bool missing_ok) { Type tup; ! if (missing_ok) ! { ! tup = LookupTypeName(pstate, typeName, typmod_p, missing_ok); ! if (tup == NULL || !((Form_pg_type) GETSTRUCT(tup))->typisdefined) ! *typeid_p = InvalidOid; ! else ! *typeid_p = HeapTupleGetOid(tup); ! ! if (tup) ! ReleaseSysCache(tup); ! } ! else ! { ! tup = typenameType(pstate, typeName, typmod_p); ! *typeid_p = HeapTupleGetOid(tup); ! ReleaseSysCache(tup); ! } } /* *************** pts_error_callback(void *arg) *** 706,714 **** * Given a string that is supposed to be a SQL-compatible type declaration, * such as "int4" or "integer" or "character varying(32)", parse * the string and convert it to a type OID and type modifier. */ void ! parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p) { StringInfoData buf; List *raw_parsetree_list; --- 721,731 ---- * Given a string that is supposed to be a SQL-compatible type declaration, * such as "int4" or "integer" or "character varying(32)", parse * the string and convert it to a type OID and type modifier. + * If the type name is not found, return InvalidOid if missing_ok + * = true, otherwise raise an error. */ void ! parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok) { StringInfoData buf; List *raw_parsetree_list; *************** parseTypeString(const char *str, Oid *ty *** 782,788 **** if (typeName->setof) goto fail; ! typenameTypeIdAndMod(NULL, typeName, typeid_p, typmod_p); pfree(buf.data); --- 799,805 ---- if (typeName->setof) goto fail; ! typenameTypeIdAndMod(NULL, typeName, typeid_p, typmod_p, missing_ok); pfree(buf.data); diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c new file mode 100644 index 5d73562..70e5a87 *** a/src/backend/utils/adt/regproc.c --- b/src/backend/utils/adt/regproc.c *************** *** 44,50 **** static char *format_operator_internal(Oid operator_oid, bool force_qualify); static char *format_procedure_internal(Oid procedure_oid, bool force_qualify); static void parseNameAndArgTypes(const char *string, bool allowNone, ! List **names, int *nargs, Oid *argtypes); /***************************************************************************** --- 44,54 ---- static char *format_operator_internal(Oid operator_oid, bool force_qualify); static char *format_procedure_internal(Oid procedure_oid, bool force_qualify); static void parseNameAndArgTypes(const char *string, bool allowNone, ! List **names, int *nargs, Oid *argtypes); ! static Oid regoper_guts(char *opr_name_or_oid, bool missing_ok); ! static Oid regproc_guts(char *pro_name_or_oid, bool missing_ok); ! static Oid regclass_guts(char *class_name_or_oid, bool missing_ok); ! static Oid regtype_guts(char *typ_name_or_oid, bool missing_ok); /***************************************************************************** *************** Datum *** 63,75 **** regprocin(PG_FUNCTION_ARGS) { char *pro_name_or_oid = PG_GETARG_CSTRING(0); RegProcedure result = InvalidOid; List *names; FuncCandidateList clist; /* '-' ? */ if (strcmp(pro_name_or_oid, "-") == 0) ! PG_RETURN_OID(InvalidOid); /* Numeric OID? */ if (pro_name_or_oid[0] >= '0' && --- 67,109 ---- regprocin(PG_FUNCTION_ARGS) { char *pro_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regproc_guts(pro_name_or_oid, false); + PG_RETURN_OID(result); + } + + /* + * to_regproc - converts "proname" to proc OID + * + * Diffrence from regprocin is, this does not throw an error if the proname + * does not exist. + * Note: this is not an I/O function. + */ + Datum + to_regproc(PG_FUNCTION_ARGS) + { + char *pro_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regproc_guts(pro_name_or_oid, true); + PG_RETURN_OID(result); + } + + /* + * Guts of regoperin and to_regproc. + * If missing_ok is true, returns InvalidOid when the proname does not exist. + */ + static Oid + regproc_guts(char *pro_name_or_oid, bool missing_ok) + { RegProcedure result = InvalidOid; List *names; FuncCandidateList clist; /* '-' ? */ if (strcmp(pro_name_or_oid, "-") == 0) ! return InvalidOid; /* Numeric OID? */ if (pro_name_or_oid[0] >= '0' && *************** regprocin(PG_FUNCTION_ARGS) *** 77,84 **** strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(pro_name_or_oid))); ! PG_RETURN_OID(result); } /* Else it's a name, possibly schema-qualified */ --- 111,118 ---- strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(pro_name_or_oid))); ! return result; } /* Else it's a name, possibly schema-qualified */ *************** regprocin(PG_FUNCTION_ARGS) *** 117,133 **** heap_close(hdesc, AccessShareLock); if (matches == 0) ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("function \"%s\" does not exist", pro_name_or_oid))); ! else if (matches > 1) ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one function named \"%s\"", ! pro_name_or_oid))); ! PG_RETURN_OID(result); } /* --- 151,176 ---- heap_close(hdesc, AccessShareLock); if (matches == 0) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("function \"%s\" does not exist", pro_name_or_oid))); ! } else if (matches > 1) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one function named \"%s\"", ! pro_name_or_oid))); ! } ! return result; } /* *************** regprocin(PG_FUNCTION_ARGS) *** 135,155 **** * pg_proc entries in the current search path. */ names = stringToQualifiedNameList(pro_name_or_oid); ! clist = FuncnameGetCandidates(names, -1, NIL, false, false, false); if (clist == NULL) ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("function \"%s\" does not exist", pro_name_or_oid))); else if (clist->next != NULL) ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one function named \"%s\"", ! pro_name_or_oid))); result = clist->oid; ! PG_RETURN_OID(result); } /* --- 178,208 ---- * pg_proc entries in the current search path. */ names = stringToQualifiedNameList(pro_name_or_oid); ! clist = FuncnameGetCandidates(names, -1, NIL, false, false, missing_ok); if (clist == NULL) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("function \"%s\" does not exist", pro_name_or_oid))); ! } else if (clist->next != NULL) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one function named \"%s\"", ! pro_name_or_oid))); ! } result = clist->oid; ! return result; } /* *************** regprocedurein(PG_FUNCTION_ARGS) *** 263,269 **** strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(pro_name_or_oid))); PG_RETURN_OID(result); } --- 316,322 ---- strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(pro_name_or_oid))); PG_RETURN_OID(result); } *************** Datum *** 431,443 **** regoperin(PG_FUNCTION_ARGS) { char *opr_name_or_oid = PG_GETARG_CSTRING(0); Oid result = InvalidOid; List *names; FuncCandidateList clist; /* '0' ? */ if (strcmp(opr_name_or_oid, "0") == 0) ! PG_RETURN_OID(InvalidOid); /* Numeric OID? */ if (opr_name_or_oid[0] >= '0' && --- 484,526 ---- regoperin(PG_FUNCTION_ARGS) { char *opr_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regoper_guts(opr_name_or_oid, false); + PG_RETURN_OID(result); + } + + /* + * to_regoper - converts "oprname" to operator OID + * + * Diffrence from regoper is, this does not throw an error if the operator + * does not exist. + * Note: this is not an I/O function. + */ + Datum + to_regoper(PG_FUNCTION_ARGS) + { + char *opr_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regoper_guts(opr_name_or_oid, true); + PG_RETURN_OID(result); + } + + /* + * Guts of regoperin and to_regoper. + * If missing_ok is true, returns InvalidOid when the operator does not exist. + */ + static Oid + regoper_guts(char *opr_name_or_oid, bool missing_ok) + { Oid result = InvalidOid; List *names; FuncCandidateList clist; /* '0' ? */ if (strcmp(opr_name_or_oid, "0") == 0) ! return InvalidOid; /* Numeric OID? */ if (opr_name_or_oid[0] >= '0' && *************** regoperin(PG_FUNCTION_ARGS) *** 445,452 **** strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(opr_name_or_oid))); ! PG_RETURN_OID(result); } /* Else it's a name, possibly schema-qualified */ --- 528,535 ---- strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(opr_name_or_oid))); ! return result; } /* Else it's a name, possibly schema-qualified */ *************** regoperin(PG_FUNCTION_ARGS) *** 485,500 **** heap_close(hdesc, AccessShareLock); if (matches == 0) ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("operator does not exist: %s", opr_name_or_oid))); else if (matches > 1) ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one operator named %s", ! opr_name_or_oid))); ! PG_RETURN_OID(result); } /* --- 568,593 ---- heap_close(hdesc, AccessShareLock); if (matches == 0) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("operator does not exist: %s", opr_name_or_oid))); ! } else if (matches > 1) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one operator named %s", ! opr_name_or_oid))); ! } ! return result; } /* *************** regoperin(PG_FUNCTION_ARGS) *** 502,522 **** * pg_operator entries in the current search path. */ names = stringToQualifiedNameList(opr_name_or_oid); ! clist = OpernameGetCandidates(names, '\0'); if (clist == NULL) ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("operator does not exist: %s", opr_name_or_oid))); else if (clist->next != NULL) ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one operator named %s", ! opr_name_or_oid))); result = clist->oid; ! PG_RETURN_OID(result); } /* --- 595,625 ---- * pg_operator entries in the current search path. */ names = stringToQualifiedNameList(opr_name_or_oid); ! clist = OpernameGetCandidates(names, '\0', missing_ok); if (clist == NULL) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_FUNCTION), ! errmsg("operator does not exist: %s", opr_name_or_oid))); ! } else if (clist->next != NULL) ! { ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_AMBIGUOUS_FUNCTION), ! errmsg("more than one operator named %s", ! opr_name_or_oid))); ! } result = clist->oid; ! return result; } /* *************** regoperout(PG_FUNCTION_ARGS) *** 558,564 **** * qualify it. */ clist = OpernameGetCandidates(list_make1(makeString(oprname)), ! '\0'); if (clist != NULL && clist->next == NULL && clist->oid == oprid) result = pstrdup(oprname); --- 661,667 ---- * qualify it. */ clist = OpernameGetCandidates(list_make1(makeString(oprname)), ! '\0', false); if (clist != NULL && clist->next == NULL && clist->oid == oprid) result = pstrdup(oprname); *************** regoperatorin(PG_FUNCTION_ARGS) *** 635,641 **** strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(opr_name_or_oid))); PG_RETURN_OID(result); } --- 738,744 ---- strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(opr_name_or_oid))); PG_RETURN_OID(result); } *************** Datum *** 804,815 **** regclassin(PG_FUNCTION_ARGS) { char *class_name_or_oid = PG_GETARG_CSTRING(0); Oid result = InvalidOid; List *names; /* '-' ? */ if (strcmp(class_name_or_oid, "-") == 0) ! PG_RETURN_OID(InvalidOid); /* Numeric OID? */ if (class_name_or_oid[0] >= '0' && --- 907,948 ---- regclassin(PG_FUNCTION_ARGS) { char *class_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regclass_guts(class_name_or_oid, false); + PG_RETURN_OID(result); + } + + /* + * to_regclass - converts "classname" to class OID + * + * Diffrence from regclassin is, this does not throw an error if the classname + * does not exist. + * Note: this is not an I/O function. + */ + Datum + to_regclass(PG_FUNCTION_ARGS) + { + char *class_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regclass_guts(class_name_or_oid, true); + PG_RETURN_OID(result); + } + + /* + * Guts of regclassin and to_regclass. + * If missing_ok is true, returns InvalidOid when the classname does not exist. + */ + static Oid + regclass_guts(char *class_name_or_oid, bool missing_ok) + { Oid result = InvalidOid; List *names; /* '-' ? */ if (strcmp(class_name_or_oid, "-") == 0) ! return result; /* Numeric OID? */ if (class_name_or_oid[0] >= '0' && *************** regclassin(PG_FUNCTION_ARGS) *** 817,824 **** strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(class_name_or_oid))); ! PG_RETURN_OID(result); } /* Else it's a name, possibly schema-qualified */ --- 950,957 ---- strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(class_name_or_oid))); ! return result; } /* Else it's a name, possibly schema-qualified */ *************** regclassin(PG_FUNCTION_ARGS) *** 848,863 **** if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) result = HeapTupleGetOid(tuple); else ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_TABLE), ! errmsg("relation \"%s\" does not exist", class_name_or_oid))); /* We assume there can be only one match */ systable_endscan(sysscan); heap_close(hdesc, AccessShareLock); ! PG_RETURN_OID(result); } /* --- 981,999 ---- if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) result = HeapTupleGetOid(tuple); else ! if (missing_ok) ! return InvalidOid; ! else ! ereport(ERROR, ! (errcode(ERRCODE_UNDEFINED_TABLE), ! errmsg("relation \"%s\" does not exist", class_name_or_oid))); /* We assume there can be only one match */ systable_endscan(sysscan); heap_close(hdesc, AccessShareLock); ! return result; } /* *************** regclassin(PG_FUNCTION_ARGS) *** 865,875 **** * pg_class entries in the current search path. */ names = stringToQualifiedNameList(class_name_or_oid); /* We might not even have permissions on this relation; don't lock it. */ ! result = RangeVarGetRelid(makeRangeVarFromNameList(names), NoLock, false); ! PG_RETURN_OID(result); } /* --- 1001,1013 ---- * pg_class entries in the current search path. */ names = stringToQualifiedNameList(class_name_or_oid); + if (names == NIL) + return InvalidOid; /* We might not even have permissions on this relation; don't lock it. */ ! result = RangeVarGetRelid(makeRangeVarFromNameList(names), NoLock, missing_ok); ! return result; } /* *************** Datum *** 968,979 **** regtypein(PG_FUNCTION_ARGS) { char *typ_name_or_oid = PG_GETARG_CSTRING(0); Oid result = InvalidOid; int32 typmod; /* '-' ? */ if (strcmp(typ_name_or_oid, "-") == 0) ! PG_RETURN_OID(InvalidOid); /* Numeric OID? */ if (typ_name_or_oid[0] >= '0' && --- 1106,1147 ---- regtypein(PG_FUNCTION_ARGS) { char *typ_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regtype_guts(typ_name_or_oid, false); + PG_RETURN_OID(result); + } + + /* + * to_regtype - converts "typename" to type OID + * + * Diffrence from regtypein is, this does not throw an error if the typename + * does not exist. + * Note: this is not an I/O function. + */ + Datum + to_regtype(PG_FUNCTION_ARGS) + { + char *typ_name_or_oid = PG_GETARG_CSTRING(0); + Oid result; + + result = regtype_guts(typ_name_or_oid, true); + PG_RETURN_OID(result); + } + + /* + * Guts of regtypein and to_regtype. + * If missing_ok is true, returns InvalidOid when the typename does not exist. + */ + static Oid + regtype_guts(char *typ_name_or_oid, bool missing_ok) + { Oid result = InvalidOid; int32 typmod; /* '-' ? */ if (strcmp(typ_name_or_oid, "-") == 0) ! return InvalidOid; /* Numeric OID? */ if (typ_name_or_oid[0] >= '0' && *************** regtypein(PG_FUNCTION_ARGS) *** 981,988 **** strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(typ_name_or_oid))); ! PG_RETURN_OID(result); } /* Else it's a type name, possibly schema-qualified or decorated */ --- 1149,1156 ---- strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(typ_name_or_oid))); ! return result; } /* Else it's a type name, possibly schema-qualified or decorated */ *************** regtypein(PG_FUNCTION_ARGS) *** 1011,1017 **** if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) result = HeapTupleGetOid(tuple); ! else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type \"%s\" does not exist", typ_name_or_oid))); --- 1179,1185 ---- if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) result = HeapTupleGetOid(tuple); ! else if (!missing_ok) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type \"%s\" does not exist", typ_name_or_oid))); *************** regtypein(PG_FUNCTION_ARGS) *** 1021,1036 **** systable_endscan(sysscan); heap_close(hdesc, AccessShareLock); ! PG_RETURN_OID(result); } /* * Normal case: invoke the full parser to deal with special cases such as * array syntax. */ ! parseTypeString(typ_name_or_oid, &result, &typmod); ! PG_RETURN_OID(result); } /* --- 1189,1204 ---- systable_endscan(sysscan); heap_close(hdesc, AccessShareLock); ! return result; } /* * Normal case: invoke the full parser to deal with special cases such as * array syntax. */ ! parseTypeString(typ_name_or_oid, &result, &typmod, missing_ok); ! return result; } /* *************** regconfigin(PG_FUNCTION_ARGS) *** 1130,1136 **** strspn(cfg_name_or_oid, "0123456789") == strlen(cfg_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(cfg_name_or_oid))); PG_RETURN_OID(result); } --- 1298,1304 ---- strspn(cfg_name_or_oid, "0123456789") == strlen(cfg_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(cfg_name_or_oid))); PG_RETURN_OID(result); } *************** regdictionaryin(PG_FUNCTION_ARGS) *** 1240,1246 **** strspn(dict_name_or_oid, "0123456789") == strlen(dict_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(dict_name_or_oid))); PG_RETURN_OID(result); } --- 1408,1414 ---- strspn(dict_name_or_oid, "0123456789") == strlen(dict_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, ! CStringGetDatum(dict_name_or_oid))); PG_RETURN_OID(result); } *************** parseNameAndArgTypes(const char *string, *** 1523,1529 **** else { /* Use full parser to resolve the type name */ ! parseTypeString(typename, &typeid, &typmod); } if (*nargs >= FUNC_MAX_ARGS) ereport(ERROR, --- 1691,1697 ---- else { /* Use full parser to resolve the type name */ ! parseTypeString(typename, &typeid, &typmod, false); } if (*nargs >= FUNC_MAX_ARGS) ereport(ERROR, diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c new file mode 100644 index 2cc8f90..7c78aaa *** a/src/backend/utils/misc/guc.c --- b/src/backend/utils/misc/guc.c *************** flatten_set_variable_args(const char *na *** 6421,6427 **** Datum interval; char *intervalout; ! typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod); Assert(typoid == INTERVALOID); interval = --- 6421,6427 ---- Datum interval; char *intervalout; ! typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod, false); Assert(typoid == INTERVALOID); interval = diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h new file mode 100644 index b30e5e8..350fafe *** a/src/include/catalog/namespace.h --- b/src/include/catalog/namespace.h *************** extern FuncCandidateList FuncnameGetCand *** 76,82 **** extern bool FunctionIsVisible(Oid funcid); extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright); ! extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind); extern bool OperatorIsVisible(Oid oprid); extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname); --- 76,83 ---- extern bool FunctionIsVisible(Oid funcid); extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright); ! extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind, ! bool missing_ok); extern bool OperatorIsVisible(Oid oprid); extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h new file mode 100644 index ad9774c..d452ae0 *** a/src/include/catalog/pg_proc.h --- b/src/include/catalog/pg_proc.h *************** DATA(insert OID = 44 ( regprocin P *** 173,178 **** --- 173,180 ---- DESCR("I/O"); DATA(insert OID = 45 ( regprocout PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2275 "24" _null_ _null_ _null_ _null_ regprocout _null_ _null_ _null_ )); DESCR("I/O"); + DATA(insert OID = 3196 ( to_regproc PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 24 "2275" _null_ _null_ _null_ _null_ to_regproc _null_ _null_ _null_ )); + DESCR("convert proname to regproc"); DATA(insert OID = 46 ( textin PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 25 "2275" _null_ _null_ _null_ _null_ textin _null_ _null_ _null_ )); DESCR("I/O"); DATA(insert OID = 47 ( textout PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2275 "25" _null_ _null_ _null_ _null_ textout _null_ _null_ _null_ )); *************** DATA(insert OID = 2214 ( regoperin PG *** 3298,3303 **** --- 3300,3307 ---- DESCR("I/O"); DATA(insert OID = 2215 ( regoperout PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2275 "2203" _null_ _null_ _null_ _null_ regoperout _null_ _null_ _null_ )); DESCR("I/O"); + DATA(insert OID = 3180 ( to_regoper PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2203 "2275" _null_ _null_ _null_ _null_ to_regoper _null_ _null_ _null_ )); + DESCR("convert operator name to regoper"); DATA(insert OID = 2216 ( regoperatorin PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2204 "2275" _null_ _null_ _null_ _null_ regoperatorin _null_ _null_ _null_ )); DESCR("I/O"); DATA(insert OID = 2217 ( regoperatorout PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2275 "2204" _null_ _null_ _null_ _null_ regoperatorout _null_ _null_ _null_ )); *************** DATA(insert OID = 2218 ( regclassin PG *** 3306,3315 **** --- 3310,3323 ---- DESCR("I/O"); DATA(insert OID = 2219 ( regclassout PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2275 "2205" _null_ _null_ _null_ _null_ regclassout _null_ _null_ _null_ )); DESCR("I/O"); + DATA(insert OID = 3197 ( to_regclass PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2205 "2275" _null_ _null_ _null_ _null_ to_regclass _null_ _null_ _null_ )); + DESCR("convert classname to regclass"); DATA(insert OID = 2220 ( regtypein PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2206 "2275" _null_ _null_ _null_ _null_ regtypein _null_ _null_ _null_ )); DESCR("I/O"); DATA(insert OID = 2221 ( regtypeout PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2275 "2206" _null_ _null_ _null_ _null_ regtypeout _null_ _null_ _null_ )); DESCR("I/O"); + DATA(insert OID = 3195 ( to_regtype PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2206 "2275" _null_ _null_ _null_ _null_ to_regtype _null_ _null_ _null_ )); + DESCR("convert type name to regtype"); DATA(insert OID = 1079 ( regclass PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2205 "25" _null_ _null_ _null_ _null_ text_regclass _null_ _null_ _null_ )); DESCR("convert text to regclass"); diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h new file mode 100644 index ab73148..b45538a *** a/src/include/parser/parse_type.h --- b/src/include/parser/parse_type.h *************** extern Type typenameType(ParseState *pst *** 27,33 **** int32 *typmod_p); extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName); extern void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, ! Oid *typeid_p, int32 *typmod_p); extern char *TypeNameToString(const TypeName *typeName); extern char *TypeNameListToString(List *typenames); --- 27,33 ---- int32 *typmod_p); extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName); extern void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, ! Oid *typeid_p, int32 *typmod_p, bool missing_ok); extern char *TypeNameToString(const TypeName *typeName); extern char *TypeNameListToString(List *typenames); *************** extern Datum stringTypeDatum(Type tp, ch *** 47,53 **** extern Oid typeidTypeRelid(Oid type_id); ! extern void parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p); #define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid) --- 47,53 ---- extern Oid typeidTypeRelid(Oid type_id); ! extern void parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok); #define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid) diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h new file mode 100644 index b90d88d..85dee8a *** a/src/include/utils/builtins.h --- b/src/include/utils/builtins.h *************** extern char *regexp_fixed_prefix(text *t *** 597,602 **** --- 597,603 ---- /* regproc.c */ extern Datum regprocin(PG_FUNCTION_ARGS); extern Datum regprocout(PG_FUNCTION_ARGS); + extern Datum to_regproc(PG_FUNCTION_ARGS); extern Datum regprocrecv(PG_FUNCTION_ARGS); extern Datum regprocsend(PG_FUNCTION_ARGS); extern Datum regprocedurein(PG_FUNCTION_ARGS); *************** extern Datum regoperin(PG_FUNCTION_ARGS) *** 607,612 **** --- 608,614 ---- extern Datum regoperout(PG_FUNCTION_ARGS); extern Datum regoperrecv(PG_FUNCTION_ARGS); extern Datum regopersend(PG_FUNCTION_ARGS); + extern Datum to_regoper(PG_FUNCTION_ARGS); extern Datum regoperatorin(PG_FUNCTION_ARGS); extern Datum regoperatorout(PG_FUNCTION_ARGS); extern Datum regoperatorrecv(PG_FUNCTION_ARGS); *************** extern Datum regclassin(PG_FUNCTION_ARGS *** 615,624 **** --- 617,628 ---- extern Datum regclassout(PG_FUNCTION_ARGS); extern Datum regclassrecv(PG_FUNCTION_ARGS); extern Datum regclasssend(PG_FUNCTION_ARGS); + extern Datum to_regclass(PG_FUNCTION_ARGS); extern Datum regtypein(PG_FUNCTION_ARGS); extern Datum regtypeout(PG_FUNCTION_ARGS); extern Datum regtyperecv(PG_FUNCTION_ARGS); extern Datum regtypesend(PG_FUNCTION_ARGS); + extern Datum to_regtype(PG_FUNCTION_ARGS); extern Datum regconfigin(PG_FUNCTION_ARGS); extern Datum regconfigout(PG_FUNCTION_ARGS); extern Datum regconfigrecv(PG_FUNCTION_ARGS); diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c new file mode 100644 index a81c185..5a92ee0 *** a/src/pl/plperl/plperl.c --- b/src/pl/plperl/plperl.c *************** plperl_spi_prepare(char *query, int argc *** 3401,3407 **** char *typstr; typstr = sv2cstr(argv[i]); ! parseTypeString(typstr, &typId, &typmod); pfree(typstr); getTypeInputInfo(typId, &typInput, &typIOParam); --- 3401,3407 ---- char *typstr; typstr = sv2cstr(argv[i]); ! parseTypeString(typstr, &typId, &typmod, false); pfree(typstr); getTypeInputInfo(typId, &typInput, &typIOParam); diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y new file mode 100644 index c0cb585..1862293 *** a/src/pl/plpgsql/src/pl_gram.y --- b/src/pl/plpgsql/src/pl_gram.y *************** parse_datatype(const char *string, int l *** 3462,3468 **** error_context_stack = &syntax_errcontext; /* Let the main parser try to parse it under standard SQL rules */ ! parseTypeString(string, &type_id, &typmod); /* Restore former ereport callback */ error_context_stack = syntax_errcontext.previous; --- 3462,3468 ---- error_context_stack = &syntax_errcontext; /* Let the main parser try to parse it under standard SQL rules */ ! parseTypeString(string, &type_id, &typmod, false); /* Restore former ereport callback */ error_context_stack = syntax_errcontext.previous; diff --git a/src/pl/plpython/plpy_spi.c b/src/pl/plpython/plpy_spi.c new file mode 100644 index 982bf84..060d514 *** a/src/pl/plpython/plpy_spi.c --- b/src/pl/plpython/plpy_spi.c *************** PLy_spi_prepare(PyObject *self, PyObject *** 113,119 **** *information for input conversion. ********************************************************/ ! parseTypeString(sptr, &typeId, &typmod); typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeId)); --- 113,119 ---- *information for input conversion. ********************************************************/ ! parseTypeString(sptr, &typeId, &typmod, false); typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeId)); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c new file mode 100644 index 0538038..c89ee7a *** a/src/pl/tcl/pltcl.c --- b/src/pl/tcl/pltcl.c *************** pltcl_SPI_prepare(ClientData cdata, Tcl_ *** 2161,2167 **** typIOParam; int32 typmod; ! parseTypeString(args[i], &typId, &typmod); getTypeInputInfo(typId, &typInput, &typIOParam); --- 2161,2167 ---- typIOParam; int32 typmod; ! parseTypeString(args[i], &typId, &typmod, false); getTypeInputInfo(typId, &typInput, &typIOParam); diff --git a/src/test/regress/expected/regproc.out b/src/test/regress/expected/regproc.out new file mode 100644 index ...80a1e29 *** a/src/test/regress/expected/regproc.out --- b/src/test/regress/expected/regproc.out *************** *** 0 **** --- 1,188 ---- + -- + -- regproc + -- + /* Objects exist, ok. */ + -- without schemaname + SELECT regoper('||/'); + regoper + --------- + ||/ + (1 row) + + SELECT regproc('now'); + regproc + --------- + now + (1 row) + + SELECT regclass('pg_class'); + regclass + ---------- + pg_class + (1 row) + + SELECT regtype('integer'); + regtype + --------- + integer + (1 row) + + SELECT to_regoper('||/'); + to_regoper + ------------ + ||/ + (1 row) + + SELECT to_regproc('now'); + to_regproc + ------------ + now + (1 row) + + SELECT to_regclass('pg_class'); + to_regclass + ------------- + pg_class + (1 row) + + SELECT to_regtype('int4'); + to_regtype + ------------ + integer + (1 row) + + -- with schemaname + SELECT regoper('pg_catalog.||/'); + regoper + --------- + ||/ + (1 row) + + SELECT regproc('pg_catalog.now'); + regproc + --------- + now + (1 row) + + SELECT regclass('pg_catalog.pg_class'); + regclass + ---------- + pg_class + (1 row) + + SELECT regtype('pg_catalog.int4'); + regtype + --------- + integer + (1 row) + + SELECT to_regoper('pg_catalog.||/'); + to_regoper + ------------ + ||/ + (1 row) + + SELECT to_regproc('pg_catalog.now'); + to_regproc + ------------ + now + (1 row) + + SELECT to_regclass('pg_catalog.pg_class'); + to_regclass + ------------- + pg_class + (1 row) + + SELECT to_regtype('pg_catalog.int4'); + to_regtype + ------------ + integer + (1 row) + + /* Objects don't exist, error. */ + -- without schemaname + SELECT regoper('||//'); + ERROR: operator does not exist: ||// + LINE 3: SELECT regoper('||//'); + ^ + SELECT regproc('know'); + ERROR: function "know" does not exist + LINE 1: SELECT regproc('know'); + ^ + SELECT regclass('pg_classes'); + ERROR: relation "pg_classes" does not exist + LINE 1: SELECT regclass('pg_classes'); + ^ + SELECT regtype('int3'); + ERROR: type "int3" does not exist + LINE 1: SELECT regtype('int3'); + ^ + -- with schemaname + SELECT regoper('ng_catalog.||/'); + ERROR: schema "ng_catalog" does not exist + LINE 1: SELECT regoper('ng_catalog.||/'); + ^ + SELECT regproc('ng_catalog.now'); + ERROR: schema "ng_catalog" does not exist + LINE 1: SELECT regproc('ng_catalog.now'); + ^ + SELECT regclass('ng_catalog.pg_class'); + ERROR: schema "ng_catalog" does not exist + LINE 1: SELECT regclass('ng_catalog.pg_class'); + ^ + SELECT regtype('ng_catalog.int4'); + ERROR: schema "ng_catalog" does not exist + LINE 1: SELECT regtype('ng_catalog.int4'); + ^ + /* Objects don't exist, but no error. */ + -- without schemaname + SELECT to_regoper('||//'); + to_regoper + ------------ + 0 + (1 row) + + SELECT to_regproc('know'); + to_regproc + ------------ + - + (1 row) + + SELECT to_regclass('pg_classes'); + to_regclass + ------------- + - + (1 row) + + SELECT to_regtype('int3'); + to_regtype + ------------ + - + (1 row) + + -- with schemaname + SELECT to_regoper('ng_catalog.||/'); + to_regoper + ------------ + 0 + (1 row) + + SELECT to_regproc('ng_catalog.now'); + to_regproc + ------------ + - + (1 row) + + SELECT to_regclass('ng_catalog.pg_class'); + to_regclass + ------------- + - + (1 row) + + SELECT to_regtype('ng_catalog.int4'); + to_regtype + ------------ + - + (1 row) + diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule new file mode 100644 index 5758b07..36c1ece *** a/src/test/regress/parallel_schedule --- b/src/test/regress/parallel_schedule *************** test: tablespace *** 13,19 **** # ---------- # The first group of parallel tests # ---------- ! test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric txid uuid enum money rangetypes # Depends on things setup during char, varchar and text test: strings --- 13,19 ---- # ---------- # The first group of parallel tests # ---------- ! test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric txid uuid enum money rangetypes regproc # Depends on things setup during char, varchar and text test: strings diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule new file mode 100644 index 78348f5..9a54d7c *** a/src/test/regress/serial_schedule --- b/src/test/regress/serial_schedule *************** test: uuid *** 19,24 **** --- 19,25 ---- test: enum test: money test: rangetypes + test: regproc test: strings test: numerology test: point diff --git a/src/test/regress/sql/regproc.sql b/src/test/regress/sql/regproc.sql new file mode 100644 index ...2bbcea0 *** a/src/test/regress/sql/regproc.sql --- b/src/test/regress/sql/regproc.sql *************** *** 0 **** --- 1,61 ---- + -- + -- regproc + -- + + /* Objects exist, ok. */ + + -- without schemaname + + SELECT regoper('||/'); + SELECT regproc('now'); + SELECT regclass('pg_class'); + SELECT regtype('integer'); + + SELECT to_regoper('||/'); + SELECT to_regproc('now'); + SELECT to_regclass('pg_class'); + SELECT to_regtype('int4'); + + -- with schemaname + + SELECT regoper('pg_catalog.||/'); + SELECT regproc('pg_catalog.now'); + SELECT regclass('pg_catalog.pg_class'); + SELECT regtype('pg_catalog.int4'); + + SELECT to_regoper('pg_catalog.||/'); + SELECT to_regproc('pg_catalog.now'); + SELECT to_regclass('pg_catalog.pg_class'); + SELECT to_regtype('pg_catalog.int4'); + + /* Objects don't exist, error. */ + + -- without schemaname + + SELECT regoper('||//'); + SELECT regproc('know'); + SELECT regclass('pg_classes'); + SELECT regtype('int3'); + + -- with schemaname + + SELECT regoper('ng_catalog.||/'); + SELECT regproc('ng_catalog.now'); + SELECT regclass('ng_catalog.pg_class'); + SELECT regtype('ng_catalog.int4'); + + /* Objects don't exist, but no error. */ + + -- without schemaname + + SELECT to_regoper('||//'); + SELECT to_regproc('know'); + SELECT to_regclass('pg_classes'); + SELECT to_regtype('int3'); + + -- with schemaname + + SELECT to_regoper('ng_catalog.||/'); + SELECT to_regproc('ng_catalog.now'); + SELECT to_regclass('ng_catalog.pg_class'); + SELECT to_regtype('ng_catalog.int4');