Simple Parse Tree

It was amazing cognac time and talking about parser with a good old college friend. E.g. to demonstrate how PostgreSQL analyses some queries.

Statement

SELECT field1 AS customer FROM “FooSchema”.”Bar”

inside server’s brain will become:

stmtmulti
    stmt
        SelectStmt
            select_no_parens
                simple_select
                    SELECT
                    target_list
                        target_el
                            a_expr
                                c_expr
                                    columnref
                                        relation_name
                                            ColId
                                                field1
                            AS
                            ColLabel
                                customer
                    from_clause
                        FROM
                        from_list
                            table_ref
                                relation_expr
                                    qualified_name
                                        relation_name
                                            ColId
                                                "FooSchema"
                                        indirection
                                            indirection_el
                                                .
                                                attr_name
                                                    ColLabel
                                                        "Bar"

Will add some more in case of interest🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s