> -----Original Message-----
> From: Tom Lane [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 11, 2005 10:55 AM
> To: Dave Held
> Cc: pgsql-hackers@postgresql.org
> Subject: Re: [HACKERS] Oracle Style packages on postgres
> 
> 
> "Dave Held" <[EMAIL PROTECTED]> writes:
> > The rule is simple: when the identifier has
> > more than two parts, search for the first part among the schemas 
    ^^^^^^^^^^^^^^^^^^^
> > first, and then the catalogs.
> 
> This doesn't actually work, because there is already ambiguity as to
> which level the first name is.  See for instance the comments in
> transformColumnRef().

I don't follow.  switch (numnames) case 3 is unambiguous under either
syntax.  case 1 and 2 are unchanged under my proposed rules.  It's
really only case 4+ that is affected.  And the change is as follows:

    if (numnames > MAX_SCHEMA_DEPTH + 3)
    {
        ereport(ERROR,
                (errcode(ERRCODE_SYNTAX_ERROR),
        errmsg("improper qualified name (too many dotted names): %s",
               NameListToString(cref->fields))));
        return NULL;
    }
    switch (numnames)
    {
    case 1: ...
    case 2: ...
    case 3: ...
    default:
        {
            char* name[MAX_SCHEMA_DEPTH + 3];
            char** i;
            char** end = name + numnames;
            char* colname = name + numnames - 1;
            for (i = name; i != end; ++i)
            {
                /* definition of lnth() should be easy enough to infer */
                *i = strVal(lnth(cref->fields));
            }

            /*
             * We check the catalog name and then ignore it.
             */
                if (!isValidNamespace(name[0]))
            {
                if (strcmp(name[0], get_database_name(MyDatabaseId)) != 0)
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                             errmsg("cross-database references are not 
implemented: %s",
                                    NameListToString(cref->fields))));
                i = name + 1;
                numnames -= 3;
            }
            else
            {
                i = name;
                numnames -= 2;            }
            /*
             * isValidNamespace() should work like LookupExplicitNamespace()
             * except that it should return false on failure instead of
             * raising an error
             */

            /* Whole-row reference? */
            if (strcmp(end[-1], "*") == 0)
            {
                node = transformWholeRowRef(pstate, i, numnames, end[-2]);
                break;
            }
            /*
             * Here I've changed the signature of transformWholeRowRef() to
             * accept a char** and an int for the schema names
             */

            /* Try to identify as a twice-qualified column */
            node = qualifiedNameToVar(pstate, i, numnames, end[-1], true);
            /*
             * And obviously we have to hack qualifiedNameToVar() similarly
             */
            if (node == NULL)
            {
                /* Try it as a function call */
                node = transformWholeRowRef(pstate, i, numnames, end[-2]);
                node = ParseFuncOrColumn(pstate,
                                       list_make1(makeString(end[-1])),
                                         list_make1(node),
                                         false, false, true);
            }
            break;
        }
    }

What am I missing?

__
David B. Held
Software Engineer/Array Services Group
200 14th Ave. East,  Sartell, MN 56377
320.534.3637 320.253.7800 800.752.8129

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to