List:Commits« Previous MessageNext Message »
From:Guilhem Bichot Date:September 20 2010 8:12am
Subject:bzr commit into mysql-next-mr-bugfixing branch (guilhem:3204)
View as plain text  
#At file:///home/mysql_src/bzrrepos_new/mysql-next-mr-opt-backporting-wl4800/ based on revid:guilhem@stripped

 3204 Guilhem Bichot	2010-09-20
      a Python script to validate that the traces found in a result file are JSON-compliant
      (currently they are not because " and newlines in queries are not escaped)

    added:
      WL4800_validate_json.py
    modified:
      WL4800_Doxyfile
      WL4800_extract_plans.py
      WL4800_select_to_explain_test.py
      sql/opt_trace.cc
      sql/opt_trace.h
      unittest/gunit/opt_trace-t.cc
=== modified file 'WL4800_Doxyfile'
--- a/WL4800_Doxyfile	2010-09-05 16:08:07 +0000
+++ b/WL4800_Doxyfile	2010-09-20 08:12:18 +0000
@@ -1,5 +1,20 @@
 # Doxyfile 1.6.1
 
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; version 2 of the License.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project
 #

=== modified file 'WL4800_extract_plans.py'
--- a/WL4800_extract_plans.py	2010-05-24 18:38:10 +0000
+++ b/WL4800_extract_plans.py	2010-09-20 08:12:18 +0000
@@ -1,5 +1,20 @@
 #! /usr/bin/python
 
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; version 2 of the License.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
 import sys
 
 usage = """

=== modified file 'WL4800_select_to_explain_test.py'
--- a/WL4800_select_to_explain_test.py	2010-09-04 17:40:51 +0000
+++ b/WL4800_select_to_explain_test.py	2010-09-20 08:12:18 +0000
@@ -1,5 +1,20 @@
 #! /usr/bin/python
 
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; version 2 of the License.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
 import sys, re
 
 usage = """

=== added file 'WL4800_validate_json.py'
--- a/WL4800_validate_json.py	1970-01-01 00:00:00 +0000
+++ b/WL4800_validate_json.py	2010-09-20 08:12:18 +0000
@@ -0,0 +1,65 @@
+#! /usr/bin/python
+
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; version 2 of the License.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+import sys
+
+usage = """
+Usage:
+  %s <a_file>
+
+It will verify that all optimizer traces of a_file (usually a_file
+is a .result or .reject file which contains
+SELECT * FROM OPTIMIZER_TRACE; ) are JSON-compliant
+""" % sys.argv[0]
+
+if len(sys.argv) != 2:
+    print usage
+    sys.exit(1)
+
+import json, re
+
+def check(trace, first_trace_line):
+    s = "".join(trace)
+    try:
+        json.loads(s)
+    except:
+        print "error at line", first_trace_line
+        print sys.exc_info()
+        print s
+    else:
+        print "ok at line", first_trace_line
+    print
+
+all = open(sys.argv[1]).readlines()
+
+first_trace_line = trace_line = 0
+trace = None
+for l in all:
+    trace_line += 1
+    if l == "{\n":
+        assert first_trace_line == 0
+        trace = []
+        first_trace_line = trace_line
+    if l.startswith("}\t") or l.startswith("}\n"): # end of current trace
+        assert first_trace_line != 0
+        trace.append("}") # eliminate any following columns of table (OS_MALLOC_ERROR etc)
+        check(trace, first_trace_line)
+        first_trace_line = 0
+    if first_trace_line != 0:
+        # eliminate /* */ (not valid JSON)
+        no_comment = re.sub("/\*.*\*/", "", l)
+        trace.append(no_comment)

=== modified file 'sql/opt_trace.cc'
--- a/sql/opt_trace.cc	2010-09-18 16:25:43 +0000
+++ b/sql/opt_trace.cc	2010-09-20 08:12:18 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/opt_trace.h'
--- a/sql/opt_trace.h	2010-09-18 16:25:43 +0000
+++ b/sql/opt_trace.h	2010-09-20 08:12:18 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'unittest/gunit/opt_trace-t.cc'
--- a/unittest/gunit/opt_trace-t.cc	2010-09-18 16:25:43 +0000
+++ b/unittest/gunit/opt_trace-t.cc	2010-09-20 08:12:18 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by


Attachment: [text/bzr-bundle] bzr/guilhem@mysql.com-20100920081218-3r0d16cbtwuup7hp.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (guilhem:3204) Guilhem Bichot20 Sep