Doubt in parser

Started by Dhanaraj Mabout 20 years ago5 messageshackers
Jump to latest
#1Dhanaraj M
Dhanaraj.M@Sun.COM

hi

currently i looking at the postgres src code. I saw the scanner and
parser implemetations at two different places (src/backend/parser/ and
/src/bakend/bootstrp). Can anybody tell me the purpose of having two
phases?? or will this help to parse the queries at different levels?

Thanks
Dhanaraj

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Dhanaraj M (#1)
Re: Doubt in parser

On Thu, Feb 16, 2006 at 06:07:25PM +0530, Dhanaraj wrote:

hi

currently i looking at the postgres src code. I saw the scanner and
parser implemetations at two different places (src/backend/parser/ and
/src/bakend/bootstrp). Can anybody tell me the purpose of having two
phases?? or will this help to parse the queries at different levels?

The first one is the actual parser for queries you send. The latter is
the bootstrap parser which is only used during the inital bootstrap of
a database. It needs to be seperate because of things like the names of
columns are stored in a pg_attribute, yet how can you fill the table if
you don't know what the columns are called.

The latter is basically a glorified data loader to handle this special
case. It can't do queries or anything like that. You can basically
ignore it for normal development.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Dhanaraj M (#1)
Re: Doubt in parser

Dhanaraj wrote:

hi

currently i looking at the postgres src code. I saw the scanner and
parser implemetations at two different places (src/backend/parser/ and
/src/bakend/bootstrp). Can anybody tell me the purpose of having two
phases?? or will this help to parse the queries at different levels?

The bootstrap parser is using only in bootstrap mode, which is when the
template1 database is initially created. It has a completely different
syntax than the main parser.

If what you are looking for is to implement a new command or modify an
existing one, ignore the bootstrap parser.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#4Michael Glaesemann
grzm@seespotcode.net
In reply to: Dhanaraj M (#1)
Re: Doubt in parser

On Feb 16, 2006, at 21:37 , Dhanaraj wrote:

hi

currently i looking at the postgres src code. I saw the scanner and
parser implemetations at two different places (src/backend/parser/
and /src/bakend/bootstrp). Can anybody tell me the purpose of
having two phases?? or will this help to parse the queries at
different levels?

AFAIK, I don't think the code is exactly the same (though I haven't
checked). The bootstrap code is used to get the PostgreSQL server
started: there is a considerable amount of information stored in the
system catalogs that the server needs to use. The server needs access
to a scanner/parser to be able to read this information. The
bootstrap code provides the server with enough knowledge to get
started. The backend parser and scanner is more feature-filled.

Someone please feel free to step in and correct me if I'm off base :)

Michael Glaesemann
grzm myrealbox com

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Glaesemann (#4)
Re: Doubt in parser

Michael Glaesemann <grzm@myrealbox.com> writes:

On Feb 16, 2006, at 21:37 , Dhanaraj wrote:

currently i looking at the postgres src code. I saw the scanner and
parser implemetations at two different places (src/backend/parser/
and /src/bakend/bootstrp). Can anybody tell me the purpose of
having two phases?? or will this help to parse the queries at
different levels?

AFAIK, I don't think the code is exactly the same (though I haven't
checked).

No, not even close. The bootstrap parser reads the "bki" language
defined here:
http://developer.postgresql.org/docs/postgres/bki.html

"bki" is simple enough that it's hardly even worth using a bison parser
for, but someone did it that way so that's what we've got.

regards, tom lane