Re: "unexpected" query behaviour after i change parser code
От | Robert Haas |
---|---|
Тема | Re: "unexpected" query behaviour after i change parser code |
Дата | |
Msg-id | AANLkTim79q7X9NUviYlW3iQhe8TFgMeV8sqVaAvDZAmc@mail.gmail.com обсуждение исходный текст |
Ответ на | "unexpected" query behaviour after i change parser code (Mohammad Heykal Abdillah <heykal.abdillah@gmail.com>) |
Ответы |
Re: "unexpected" query behaviour after i change parser
code
(Mohammad Heykal Abdillah <heykal.abdillah@gmail.com>)
|
Список | pgsql-hackers |
On Sat, May 22, 2010 at 9:21 AM, Mohammad Heykal Abdillah <heykal.abdillah@gmail.com> wrote: > All, > > Lately i have play with "parser"-part. I was try to make valid query > command without using "FROM clause", so far it's work. > > I know this modification will make all query that using "FROM clause" > failed, for example "/df" command. But normal or simple "select > statement" so far is work. > > Now before my question, this what i do to make query without FROM clause > work : > 1) change "src/backend/parser/gram.y" at "simple_select:" delete > from_clause > 2) change "src/backend/parser/parse_relation.c" at function > warnAutoRange, comment or delete "if (!add_missing_from)" part and > change the "else" above to "if (add_missing_from)". > > Ok this my test result to "customer" and "item" table : > - select id_item,name from item; > --> failed, because there is "from clause" (failed like i expected) > > - select item.id_item, item.name; > --> work, like i expected > > - select id_item,name; > --> failed, with error : column "id_item" does not exist (failed like i > expected) > > - select item.id_item,customer.fname; > --> work, the data not acurate though because there is no joined atribut > > - select item.id_item,customer.fname where item.id_item=customer.id; > --> work, normaly > > - select item.id,item; > --> work, the result was concanted in "item" column. (i expected this > query was failed). Try many combination including using more than one > table with previous test, the result always work ONLY IF i put > "table_name.colId" first. > > My question : > 1) Can someone explain why my last test it's work? In standard PostgreSQL, "select item from item" is valid SQL. It returns a single column whose value is a record containing all the columns from the item table. I suspect something similar is happening in your case. > 2) Why PostgreSQL won't query my 3rd test? > Considering my last test it's work. I'm not sure which test you're referring to here, but all of your results look like about what would happen with adding_missing_from set. Which brings me to another point: I'm not really sure what you're trying to accomplish with this modification, considering that adding_missing_from sounds like it does about what you want, but without breaking nearly as much stuff. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company
В списке pgsql-hackers по дате отправления: