Giter VIP home page Giter VIP logo

Comments (4)

rafiss avatar rafiss commented on June 26, 2024 1

@Vidyap23 sure, feel free to submit a PR. Review our contribution guidelines here: https://cockroachlabs.atlassian.net/wiki/spaces/CRDB/pages/73072641/What+is+a+Good+CockroachDB+PR

I recommend fixing this by modifying the MergeWith function so that it accepts a SearchPath parameter.

func (fd *ResolvedFunctionDefinition) MergeWith(
another *ResolvedFunctionDefinition,
) (*ResolvedFunctionDefinition, error) {

When it combines the two lists, it should make sure they are ordered by the order the schemas appear when using SearchPath.Iter().

To test this, you can use the example that @michae2 wrote above. You can add that test to pkg/sql/logictest/testdata/logic_test/udf.

from cockroach.

rafiss avatar rafiss commented on June 26, 2024

I haven't looked into what the code is doing right now, but the thing we want it to use when resolving the name is (sessiondata.SearchPath).Iter():

// Iter returns an iterator through the search path. We must include the
// implicit pg_catalog and temporary schema at the beginning of the search path,
// unless they have been explicitly set later by the user.
// We also include pg_extension in the path, as this normally be used in place
// of the public schema. This should be read before "public" is read.
// "The system catalog schema, pg_catalog, is always searched, whether it is
// mentioned in the path or not. If it is mentioned in the path then it will be
// searched in the specified order. If pg_catalog is not in the path then it
// will be searched before searching any of the path items."
// "Likewise, the current session's temporary-table schema, pg_temp_nnn, is
// always searched if it exists. It can be explicitly listed in the path by
// using the alias pg_temp. If it is not listed in the path then it is searched
// first (even before pg_catalog)."
// - https://www.postgresql.org/docs/9.1/static/runtime-config-client.html
func (s SearchPath) Iter() SearchPathIter {
implicitPgTempSchema := !s.containsPgTempSchema && s.tempSchemaName != ""
sp := SearchPathIter{
paths: s.paths,
implicitPgCatalog: !s.containsPgCatalog,
implicitPgExtension: !s.containsPgExtension,
implicitPgTempSchema: implicitPgTempSchema,
tempSchemaName: s.tempSchemaName,
userSchemaName: s.userSchemaName,
duplicatedIndexes: s.duplicatedIndexes,
}
return sp
}

from cockroach.

rafiss avatar rafiss commented on June 26, 2024

The code that needs to be fixed is:

// Get builtin and udf functions if there is any match.
builtinDef, err := tree.GetBuiltinFuncDefinition(fn, path)
if err != nil {
return nil, err
}
udfDef, err := maybeLookUpUDF(ctx, sr, path, fn)
if err != nil {
return nil, err
}
switch {
case builtinDef != nil && udfDef != nil:
return builtinDef.MergeWith(udfDef)

as well as possibly other implementations of ResolveFunction. I think the MergeWith function should be updated so that it orders the overloads by search path.

from cockroach.

Vidyap23 avatar Vidyap23 commented on June 26, 2024

Hi @rafiss I would like to work on this issue, if no one has picked it up yet

from cockroach.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.