Thread: postgresMain() function

postgresMain() function

From
mohsen soodkhah mohammadi
Date:
hello .
In Postgres.c we have a switch for firstchar .  one of case of them is : case 'Q' that is for simple queries.
I want to know the other cases were for what operations .
and:
is the case with  'Q' parameter for DDL and DML commands?

Re: postgresMain() function

From
Amit Kapila
Date:
On Sunday, July 07, 2013 3:46 PM mohsen soodkhah mohammadi wrote:

> hello .
> In Postgres.c we have a switch for firstchar .  one of case of them is :
case 'Q' that is for simple queries.
> I want to know the other cases were for what operations .
> and:
> is the case with  'Q' parameter for DDL and DML commands?

SQL Commands can be executed using 2 sub-protocols, 'simple query' ,
'extended query'

In 'simple query' protocol, the frontend just sends a textual query string,
which is parsed and immediately executed by the backend.
In 'extended query' protocol, processing of queries is separated into
multiple steps: parsing, binding of parameter values, and execution.

'Q' message is used for 'simple query'. It can be used for any SQL command
'P', 'B', 'E' are most important messages for 'extended query', these are
used for prepared statements.

You can read the below link for detailed message flow description:
http://www.postgresql.org/docs/devel/static/protocol.html

With Regards,
Amit Kapila.