Re: Oracle Style packages on postgres - Mailing list pgsql-hackers
From | Dave Held |
---|---|
Subject | Re: Oracle Style packages on postgres |
Date | |
Msg-id | 49E94D0CFCD4DB43AFBA928DDD20C8F902618509@asg002.asg.local Whole thread Raw |
In response to | Oracle Style packages on postgres (rmm@sqlisor.com) |
Responses |
Re: Oracle Style packages on postgres
|
List | pgsql-hackers |
> -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > 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" <dave.held@arraysg.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("improperqualified name (too many dotted names): %s", NameListToString(cref->fields)))); returnNULL; } 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 enoughto 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-databasereferences are not implemented: %s", NameListToString(cref->fields)))); i = name + 1; numnames -= 3; } else { i = name; numnames -= 2; } /* * isValidNamespace() shouldwork 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 changedthe 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
pgsql-hackers by date: