happyiwin / common-schema

Automatically exported from code.google.com/p/common-schema
0 stars 0 forks source link

SQL dependency check error on "UPDATE QUERY" #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Which version of common_schema are you using? (specify
revision+distribution)
=> common_schema-1.3.sql

Which component is failing? (specify the view, function, etc.)
=> Procedure Error, Update check is not valid!

What is the expected output? What do you see instead?
=> If check sql dependency, it should report out the right table name, but out 
"SET" as table name.

Can you provide with sample data?
sql> call get_sql_dependencies('update test set i = 1', 'dbatest');
+-------------+-------------+-------------+--------+
| schema_name | object_name | object_type | action |
+-------------+-------------+-------------+--------+
| dbatest     | set         | table       | update |
+-------------+-------------+-------------+--------+

Also I find out what cause the result. This result from pattern of "UPDATE 
QUERY", which expected table name right after "UPDATE" sentence.
you can check "_get_sql_dependencies_internal.sql" file and go to 72 Line.
I changed some actions for "update query" like this. 

#### Original
                    if v_token in ('alter', 'call', 'create', 'delete', 'drop', 'insert', 'replace', 'select', 'truncate', 'update') then
                        set v_action = lower(v_token) collate utf8_general_ci
                        ,   v_scan_state = v_action
                        ;

#### Fixed
                    if v_token in ('alter', 'call', 'create', 'delete', 'drop', 'insert', 'replace', 'select', 'truncate') then
                        set v_action = lower(v_token) collate utf8_general_ci
                        ,   v_scan_state = v_action
                        ;
                    elseif v_token in ('update') then
                        set v_action = lower(v_token) collate utf8_general_ci
                        ,   v_scan_state = 'expect table'
                        ;

I hope to change this bugs, and I also want to add other dependency check like 
"TRIGGER". 

Thank you.

From Chris in South Korea.

Original issue reported on code.google.com by gyw...@gmail.com on 22 Jan 2013 at 1:23

GoogleCodeExporter commented 8 years ago
Thank you for this bug fix. It will be incorporated just now.

All the sql dependency routines are still considered to be BETA. They're 
actually not even part of the test process.

If you have the will and time to continue work on this -- I'm more than happy. 
Also best to start producing test plans.

Original comment by shlomi.n...@gmail.com on 3 Feb 2013 at 8:04

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r428.

Original comment by shlomi.n...@gmail.com on 3 Feb 2013 at 8:04

GoogleCodeExporter commented 8 years ago
Fix released in 1.3.1

Original comment by shlomi.n...@gmail.com on 3 Feb 2013 at 8:49

GoogleCodeExporter commented 8 years ago
Thankx.
I also fixed other problemes by myself.
I'll test for a while, and then share with you~~

Original comment by gyw...@gmail.com on 5 Feb 2013 at 1:26