Re: Oracle Style packages on postgres

From: "Dave Held" <dave(dot)held(at)arraysg(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Oracle Style packages on postgres
Date: 2005-05-11 16:54:40
Message-ID: 49E94D0CFCD4DB43AFBA928DDD20C8F902618509@asg002.asg.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Wednesday, May 11, 2005 10:55 AM
> To: Dave Held
> Cc: pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] Oracle Style packages on postgres
>
>
> "Dave Held" <dave(dot)held(at)arraysg(dot)com> 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2005-05-11 17:05:13 7.3.10 working
Previous Message Andreas Pflug 2005-05-11 16:44:21 Server instrumentation for 8.1