You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafodion.apache.org by "Liu, Ming (Ming)" <mi...@esgyn.cn> on 2018/03/13 03:01:02 UTC

How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Hi, Trafodion developers,

I am trying to figure out the code path of building the default value of column definition.

In the parser yacc file, the default value is treated as type ElemDDLColDefault, for example:

                      | builtin_function_user
                                {
                                  $$ = new (PARSERHEAP())
                                    ElemDDLColDefault(
                                       ElemDDLColDefault::COL_DEFAULT,
                                       $1 /*builtin_function_user*/);
                                }

And later in the code CmpSeabaseDDL::buildColInfoArray, it all uses ElemDDLColDef for a given column. I cannot find where the population of ElemDDLColDef is done.
I need to transfer some information from parser to later phases for semantic checking. Reading the code for a while, but no good progress, anyone know this will help me a lot.

I modified the ElemDDLColDefault with an error code which can easily detected at parse time. Later, in semantic checking can properly report this error, since in the parser production, it is very hard to know the column name, have to postpone the error report in later phases. But DDL is not DML, there is no clear Bind phase, so I am lost here.

Thanks,
Ming

RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Posted by "Liu, Ming (Ming)" <mi...@esgyn.cn>.
Thanks Hans, let me check them.

Ming

-----Original Message-----
From: Hans Zeller <ha...@esgyn.com> 
Sent: Wednesday, March 14, 2018 3:17 AM
To: dev@trafodion.apache.org
Subject: RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Hi Ming,

You mention "Trafodion never did semantics checking in the parser?" Actually, I think it is ok to raise errors in the parser when it is clear from the syntax that there is an error. You should not look up any metadata information in the parser, though.

There are many places in the parser where it raises errors, not just generic syntax errors, you can search for "DgSqlCode" in file core/sql/parser/sqlparser.y to see examples.

Thanks,

Hans

-----Original Message-----
From: Liu, Ming (Ming) <mi...@esgyn.cn> 
Sent: Monday, March 12, 2018 11:31 PM
To: dev@trafodion.apache.org
Subject: RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Thanks Anoop, 

That is the method I am looking for, this helps a lot!

I agree with you, let me debug it and try to find the best way to do the semantics checking. 

Trafodion never did semantics checking in the parser? It is much easier in my case, but let me follow the standard :-)

Thanks,
Ming

-----Original Message-----
From: Anoop Sharma <an...@esgyn.com>
Sent: Tuesday, March 13, 2018 11:59 AM
To: dev@trafodion.apache.org
Subject: RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

ElemDDLColDef is created in parser (sqlparser.y) as part of column_definition production when a column is specified.
Fields are adjusted/populated in file ElemDDLCol.cpp in method setColumnAttribute.

My suggestion would be to go through sqlparser.y, ElemDDL*.cpp, StmtDDLCreate.cpp(and others), and BindStmtDDL.cpp in parser dir to see the flow of how column definitions are created and set. 
Look at the code, go through the sequence in gdb, ask questions, etc before making changes. 

That will give a better understanding of the flow and will help in making better decision on how/where to make changes. Should it be done in parser, in binder, in sqlcomp. Should it be done when DDL is compiled or when it is executed.
Changes may still work but without an overall understanding of code flow in that area, you may miss something.

Emails are good to get idea and direction but ultimately understanding the architecture by reading code and debugging is the way to go.

anoop

-----Original Message-----
From: Liu, Ming (Ming) <mi...@esgyn.cn>
Sent: Monday, March 12, 2018 8:01 PM
To: dev@trafodion.apache.org
Subject: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Hi, Trafodion developers,

I am trying to figure out the code path of building the default value of column definition.

In the parser yacc file, the default value is treated as type ElemDDLColDefault, for example:

                      | builtin_function_user
                                {
                                  $$ = new (PARSERHEAP())
                                    ElemDDLColDefault(
                                       ElemDDLColDefault::COL_DEFAULT,
                                       $1 /*builtin_function_user*/);
                                }

And later in the code CmpSeabaseDDL::buildColInfoArray, it all uses ElemDDLColDef for a given column. I cannot find where the population of ElemDDLColDef is done.
I need to transfer some information from parser to later phases for semantic checking. Reading the code for a while, but no good progress, anyone know this will help me a lot.

I modified the ElemDDLColDefault with an error code which can easily detected at parse time. Later, in semantic checking can properly report this error, since in the parser production, it is very hard to know the column name, have to postpone the error report in later phases. But DDL is not DML, there is no clear Bind phase, so I am lost here.

Thanks,
Ming

RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Posted by Hans Zeller <ha...@esgyn.com>.
Hi Ming,

You mention "Trafodion never did semantics checking in the parser?" Actually, I think it is ok to raise errors in the parser when it is clear from the syntax that there is an error. You should not look up any metadata information in the parser, though.

There are many places in the parser where it raises errors, not just generic syntax errors, you can search for "DgSqlCode" in file core/sql/parser/sqlparser.y to see examples.

Thanks,

Hans

-----Original Message-----
From: Liu, Ming (Ming) <mi...@esgyn.cn> 
Sent: Monday, March 12, 2018 11:31 PM
To: dev@trafodion.apache.org
Subject: RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Thanks Anoop, 

That is the method I am looking for, this helps a lot!

I agree with you, let me debug it and try to find the best way to do the semantics checking. 

Trafodion never did semantics checking in the parser? It is much easier in my case, but let me follow the standard :-)

Thanks,
Ming

-----Original Message-----
From: Anoop Sharma <an...@esgyn.com>
Sent: Tuesday, March 13, 2018 11:59 AM
To: dev@trafodion.apache.org
Subject: RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

ElemDDLColDef is created in parser (sqlparser.y) as part of column_definition production when a column is specified.
Fields are adjusted/populated in file ElemDDLCol.cpp in method setColumnAttribute.

My suggestion would be to go through sqlparser.y, ElemDDL*.cpp, StmtDDLCreate.cpp(and others), and BindStmtDDL.cpp in parser dir to see the flow of how column definitions are created and set. 
Look at the code, go through the sequence in gdb, ask questions, etc before making changes. 

That will give a better understanding of the flow and will help in making better decision on how/where to make changes. Should it be done in parser, in binder, in sqlcomp. Should it be done when DDL is compiled or when it is executed.
Changes may still work but without an overall understanding of code flow in that area, you may miss something.

Emails are good to get idea and direction but ultimately understanding the architecture by reading code and debugging is the way to go.

anoop

-----Original Message-----
From: Liu, Ming (Ming) <mi...@esgyn.cn>
Sent: Monday, March 12, 2018 8:01 PM
To: dev@trafodion.apache.org
Subject: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Hi, Trafodion developers,

I am trying to figure out the code path of building the default value of column definition.

In the parser yacc file, the default value is treated as type ElemDDLColDefault, for example:

                      | builtin_function_user
                                {
                                  $$ = new (PARSERHEAP())
                                    ElemDDLColDefault(
                                       ElemDDLColDefault::COL_DEFAULT,
                                       $1 /*builtin_function_user*/);
                                }

And later in the code CmpSeabaseDDL::buildColInfoArray, it all uses ElemDDLColDef for a given column. I cannot find where the population of ElemDDLColDef is done.
I need to transfer some information from parser to later phases for semantic checking. Reading the code for a while, but no good progress, anyone know this will help me a lot.

I modified the ElemDDLColDefault with an error code which can easily detected at parse time. Later, in semantic checking can properly report this error, since in the parser production, it is very hard to know the column name, have to postpone the error report in later phases. But DDL is not DML, there is no clear Bind phase, so I am lost here.

Thanks,
Ming

RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Posted by "Liu, Ming (Ming)" <mi...@esgyn.cn>.
Thanks Anoop, 

That is the method I am looking for, this helps a lot!

I agree with you, let me debug it and try to find the best way to do the semantics checking. 

Trafodion never did semantics checking in the parser? It is much easier in my case, but let me follow the standard :-)

Thanks,
Ming

-----Original Message-----
From: Anoop Sharma <an...@esgyn.com> 
Sent: Tuesday, March 13, 2018 11:59 AM
To: dev@trafodion.apache.org
Subject: RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

ElemDDLColDef is created in parser (sqlparser.y) as part of column_definition production
when a column is specified.
Fields are adjusted/populated in file ElemDDLCol.cpp in method setColumnAttribute.

My suggestion would be to go through sqlparser.y, ElemDDL*.cpp, StmtDDLCreate.cpp(and others),
and BindStmtDDL.cpp in parser dir to see the flow of how column definitions are created and set. 
Look at the code, go through the sequence in gdb, ask questions, etc before making changes. 

That will give a better understanding of the flow and will help in making better decision on
how/where to make changes. Should it be done in parser, in binder, in sqlcomp. Should it
be done when DDL is compiled or when it is executed.
Changes may still work but without an overall understanding of code flow in that area, 
you may miss something.

Emails are good to get idea and direction but ultimately understanding the architecture by
reading code and debugging is the way to go.

anoop

-----Original Message-----
From: Liu, Ming (Ming) <mi...@esgyn.cn> 
Sent: Monday, March 12, 2018 8:01 PM
To: dev@trafodion.apache.org
Subject: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Hi, Trafodion developers,

I am trying to figure out the code path of building the default value of column definition.

In the parser yacc file, the default value is treated as type ElemDDLColDefault, for example:

                      | builtin_function_user
                                {
                                  $$ = new (PARSERHEAP())
                                    ElemDDLColDefault(
                                       ElemDDLColDefault::COL_DEFAULT,
                                       $1 /*builtin_function_user*/);
                                }

And later in the code CmpSeabaseDDL::buildColInfoArray, it all uses ElemDDLColDef for a given column. I cannot find where the population of ElemDDLColDef is done.
I need to transfer some information from parser to later phases for semantic checking. Reading the code for a while, but no good progress, anyone know this will help me a lot.

I modified the ElemDDLColDefault with an error code which can easily detected at parse time. Later, in semantic checking can properly report this error, since in the parser production, it is very hard to know the column name, have to postpone the error report in later phases. But DDL is not DML, there is no clear Bind phase, so I am lost here.

Thanks,
Ming

RE: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Posted by Anoop Sharma <an...@esgyn.com>.
ElemDDLColDef is created in parser (sqlparser.y) as part of column_definition production
when a column is specified.
Fields are adjusted/populated in file ElemDDLCol.cpp in method setColumnAttribute.

My suggestion would be to go through sqlparser.y, ElemDDL*.cpp, StmtDDLCreate.cpp(and others),
and BindStmtDDL.cpp in parser dir to see the flow of how column definitions are created and set. 
Look at the code, go through the sequence in gdb, ask questions, etc before making changes. 

That will give a better understanding of the flow and will help in making better decision on
how/where to make changes. Should it be done in parser, in binder, in sqlcomp. Should it
be done when DDL is compiled or when it is executed.
Changes may still work but without an overall understanding of code flow in that area, 
you may miss something.

Emails are good to get idea and direction but ultimately understanding the architecture by
reading code and debugging is the way to go.

anoop

-----Original Message-----
From: Liu, Ming (Ming) <mi...@esgyn.cn> 
Sent: Monday, March 12, 2018 8:01 PM
To: dev@trafodion.apache.org
Subject: How and where the ElemDDLColDefault is converted into ElemDDLColDef ?

Hi, Trafodion developers,

I am trying to figure out the code path of building the default value of column definition.

In the parser yacc file, the default value is treated as type ElemDDLColDefault, for example:

                      | builtin_function_user
                                {
                                  $$ = new (PARSERHEAP())
                                    ElemDDLColDefault(
                                       ElemDDLColDefault::COL_DEFAULT,
                                       $1 /*builtin_function_user*/);
                                }

And later in the code CmpSeabaseDDL::buildColInfoArray, it all uses ElemDDLColDef for a given column. I cannot find where the population of ElemDDLColDef is done.
I need to transfer some information from parser to later phases for semantic checking. Reading the code for a while, but no good progress, anyone know this will help me a lot.

I modified the ElemDDLColDefault with an error code which can easily detected at parse time. Later, in semantic checking can properly report this error, since in the parser production, it is very hard to know the column name, have to postpone the error report in later phases. But DDL is not DML, there is no clear Bind phase, so I am lost here.

Thanks,
Ming