Changeset: 23e527024ad0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=23e527024ad0
Added Files:
        buildtools/autogen/scripts/sql2h.py
Removed Files:
        buildtools/autogen/scripts/sql2c.py
        sql/scripts/sql_scripts_hge.c
        sql/scripts/sql_scripts_hge.h
Modified Files:
        sql/Makefile.ag
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/sql_scenario.c
        sql/scripts/09_like.sql.h
        sql/scripts/10_math.sql.h
        sql/scripts/11_times.sql.h
        sql/scripts/12_url.sql.h
        sql/scripts/13_date.sql.h
        sql/scripts/14_inet.sql.h
        sql/scripts/15_querylog.sql.h
        sql/scripts/16_tracelog.sql.h
        sql/scripts/17_temporal.sql.h
        sql/scripts/18_index.sql.h
        sql/scripts/20_vacuum.sql.h
        sql/scripts/21_dependency_views.sql.h
        sql/scripts/22_clients.sql.h
        sql/scripts/23_skyserver.sql.h
        sql/scripts/25_debug.sql.h
        sql/scripts/26_sysmon.sql.h
        sql/scripts/27_rejects.sql.h
        sql/scripts/39_analytics.sql.h
        sql/scripts/39_analytics_hge.sql.h
        sql/scripts/40_json.sql.h
        sql/scripts/40_json_hge.sql.h
        sql/scripts/41_md5sum.sql.h
        sql/scripts/45_uuid.sql.h
        sql/scripts/46_profiler.sql.h
        sql/scripts/51_sys_schema_extension.sql.h
        sql/scripts/60_wlcr.sql.h
        sql/scripts/75_storagemodel.sql.h
        sql/scripts/80_statistics.sql.h
        sql/scripts/99_system.sql.h
        sql/scripts/Makefile.ag
        sql/scripts/sql_scripts.c
        sql/scripts/sql_scripts.h
Branch: translate-scripts
Log Message:

Use static C arry to hold script data, and make it compile.


diffs (truncated from 1097 to 300 lines):

diff --git a/buildtools/autogen/scripts/sql2c.py 
b/buildtools/autogen/scripts/sql2h.py
rename from buildtools/autogen/scripts/sql2c.py
rename to buildtools/autogen/scripts/sql2h.py
--- a/buildtools/autogen/scripts/sql2c.py
+++ b/buildtools/autogen/scripts/sql2h.py
@@ -11,7 +11,7 @@ import sys
 
 
 if len(sys.argv) < 2:
-    raise Exception("One argument must be given to sql2c.py")
+    raise Exception("One argument must be given to sql2h.py")
 
 sql_content_file = open(sys.argv[1], 'r')
 sql_content = sql_content_file.read()
@@ -22,40 +22,22 @@ base = os.path.basename(sys.argv[1])
 split = os.path.splitext(base)
 filebasename = split[0]
 
-sql_c_output_file = open(filebasename + ".sql.c", 'w')
 sql_h_output_file = open(filebasename + ".sql.h", 'w')
 
 # write the common header
 insert1 = (
-    '/*\n'
-    '* This Source Code Form is subject to the terms of the Mozilla Public\n'
-    '* License, v. 2.0.  If a copy of the MPL was not distributed with this\n'
-    '* file, You can obtain one at http://mozilla.org/MPL/2.0/.\n'
-    '*\n'
-    '* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.\n'
-    '*/\n'
-    '\n'
-    '// This file was generated automatically through bootstrap.py.\n// Do not 
edit this file directly.\n'
-    '\n'
-    '#include "monetdb_config.h"\n'
-    '\n'
-    '#include "{0}.sql.h"\n'
-    '#include "gdk.h"\n'
-    '#include "mal_client.h"\n'
-    '#include "sql_catalog.h"\n'
-    '\n'
-    '#include <assert.h>\n'
-    '\n'
-    'extern str SQLstatementIntern(Client c, str *expr, str nme, bit execute, 
bit output, res_table **result);\n'
-    '\n'
-    'str\n'
-    'sql_install_{0}(Client c, char *buf, size_t bufsize)\n'
-    '{{\n'
-    '\tsize_t pos = 0;\n'
-    '\n'
-    '\tpos += snprintf(buf, bufsize, "').format(filebasename, filebasename)
+'/*\n'
+'* This Source Code Form is subject to the terms of the Mozilla Public\n'
+'* License, v. 2.0.  If a copy of the MPL was not distributed with this\n'
+'* file, You can obtain one at http://mozilla.org/MPL/2.0/.\n'
+'*\n'
+'* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.\n'
+'*/\n'
+'\n'
+'// This file was generated automatically with sql2h.py. Do not edit this file 
directly.\n'
+'{{ "{0}", "').format(filebasename)
 
-sql_c_output_file.write(insert1)
+sql_h_output_file.write(insert1)
 
 # Let's remove comments from the sql script with a Markov chain :) Bugs might 
still be there
 # STATES 0 - OK, 1 in # comment, 2 in -- comment, 3 in /* comment, 4 inside ' 
string, 5 inside " string,
@@ -70,9 +52,9 @@ endloop = len(sql_content) - 1
 
 
 def write_to_buffer(input_c):
-    global current_pointer, sql_c_output_file, buffer
+    global current_pointer, sql_h_output_file, buffer
     if current_pointer == CACHE_SIZE:
-        sql_c_output_file.write("".join(buffer))
+        sql_h_output_file.write("".join(buffer))
         current_pointer = 0
     buffer[current_pointer] = input_c
     current_pointer += 1
@@ -167,43 +149,10 @@ while i < endloop:
     i += 1
 
 if current_pointer > 0:
-    sql_c_output_file.write("".join(buffer[:current_pointer]))
+    sql_h_output_file.write("".join(buffer[:current_pointer]))
 
 # insert more common stuff
-insert2 = (
-'");\n'
-'\tif (pos >= bufsize)\n'
-'\t\tthrow(SQL, "createdb.{0}", SQLSTATE(42000) "SQL script to install is too 
large");\n'
-'\tprintf("# loading sql script: {0}{1}\\n");\n'
-'\treturn SQLstatementIntern(c, &buf, "createdb.{0}", 1, 0, NULL);\n'
-'}}\n').format(filebasename, split[1])
-
-sql_c_output_file.write(insert2)
-sql_c_output_file.close()
+sql_h_output_file.write('" }}, \n'.format())
+sql_h_output_file.close()
 
-# write header file
-insert3 = (
-    '/*\n'
-    '* This Source Code Form is subject to the terms of the Mozilla Public\n'
-    '* License, v. 2.0.  If a copy of the MPL was not distributed with this\n'
-    '* file, You can obtain one at http://mozilla.org/MPL/2.0/.\n'
-    '*\n'
-    '* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.\n'
-    '*/\n'
-    '\n'
-    '// This file was generated automatically through bootstrap.py.\n// Do not 
edit this file directly.\n'
-    '\n'
-    '#ifndef SQL_{0}_H\n'
-    '#define SQL_{0}_H\n'
-    '\n'
-    '#include "monetdb_config.h"\n'
-    '\n'
-    '#include "gdk.h"\n'
-    '#include "mal_client.h"\n'
-    '\n'
-    'extern str sql_install_{1}(Client c, char *buf, size_t bufsize);\n'
-    '\n'
-    '#endif //SQL_{0}_H\n').format(filebasename.upper(), filebasename)
-
-sql_h_output_file.write(insert3)
 sql_h_output_file.close()
diff --git a/sql/Makefile.ag b/sql/Makefile.ag
--- a/sql/Makefile.ag
+++ b/sql/Makefile.ag
@@ -4,7 +4,7 @@
 #
 # Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 
-SUBDIRS = include common storage server backends scripts NATIVE_WIN32?NT
+SUBDIRS = include common storage server scripts backends NATIVE_WIN32?NT
 
 EXTRA_DIST_DIR = test benchmarks odbc/samples/Tests jdbc/tests
 
diff --git a/sql/backends/monet5/Makefile.ag b/sql/backends/monet5/Makefile.ag
--- a/sql/backends/monet5/Makefile.ag
+++ b/sql/backends/monet5/Makefile.ag
@@ -57,8 +57,7 @@ lib__sql = {
                WIN32?../../../monetdb5/tools/libmonetdb5 \
                WIN32?../../../gdk/libbat \
                WIN32?../../../common/stream/libstream \
-               WIN32?$(openssl_LIBS) \
-               HAVE_HGE?../../scripts/libsqlscriptshge
+               WIN32?$(openssl_LIBS)
 }
 
 headers_mal = {
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -46,9 +46,6 @@
 #include <unistd.h>
 #include "sql_upgrades.h"
 #include "sql_scripts.h"
-#ifdef HAVE_HGE
-#include "sql_scripts_hge.h"
-#endif
 
 static int SQLinitialized = 0;
 static int SQLnewcatalog = 0;
@@ -470,31 +467,17 @@ SQLinit(Client c)
                        SQLnewcatalog = 1;
        }
        if (SQLnewcatalog > 0) {
-               size_t bufsize = 128 * BLOCK;
-               char *buf = GDKmalloc(bufsize), *commit = "commit;\n";
+               char *commit = "commit;\n";
 
                SQLnewcatalog = 0;
                maybeupgrade = 0;
 
-               if (buf == NULL)
-                       throw(SQL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
-
                fprintf(stdout, "# SQL catalog created, loading sql scripts 
once\n");
 
-               if ((msg = install_sql_scripts(c, buf, bufsize)) != 
MAL_SUCCEED) {
+               if ((msg = install_sql_scripts(c)) != MAL_SUCCEED) {
                        MT_lock_unset(&sql_contextLock);
-                       GDKfree(buf);
                        return msg;
                }
-#ifdef HAVE_HGE
-               if ((msg = install_sql_scripts_hge(c, buf, bufsize)) != 
MAL_SUCCEED) {
-                       MT_lock_unset(&sql_contextLock);
-                       GDKfree(buf);
-                       return msg;
-               }
-#endif
-
-               GDKfree(buf);
                if ((msg = SQLstatementIntern(c, &commit, "sql.init", 1, 0, 
NULL)) != MAL_SUCCEED) {
                        MT_lock_unset(&sql_contextLock);
                        return msg;
diff --git a/sql/scripts/09_like.sql.h b/sql/scripts/09_like.sql.h
--- a/sql/scripts/09_like.sql.h
+++ b/sql/scripts/09_like.sql.h
@@ -6,17 +6,5 @@
 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 */
 
-// This file was generated automatically through bootstrap.py.
-// Do not edit this file directly.
-
-#ifndef SQL_09_LIKE_H
-#define SQL_09_LIKE_H
-
-#include "monetdb_config.h"
-
-#include "gdk.h"
-#include "mal_client.h"
-
-extern str sql_install_09_like(Client c, char *buf, size_t bufsize);
-
-#endif //SQL_09_LIKE_H
+// This file was generated automatically with sql2h.py. Do not edit this file 
directly.
+{ "09_like", " create filter function \"like\"(val string, pat string, esc 
string) external name algebra.\"like\"; create filter function \"ilike\"(val 
string, pat string, esc string) external name algebra.\"ilike\"; create filter 
function \"like\"(val string, pat string) external name algebra.\"like\"; 
create filter function \"ilike\"(val string, pat string) external name 
algebra.\"ilike\"; grant execute on filter function \"like\" (string, string, 
string) to public; grant execute on filter function \"ilike\" (string, string, 
string) to public; grant execute on filter function \"like\" (string, string) 
to public; grant execute on filter function \"ilike\" (string, string) to 
public;" }, 
diff --git a/sql/scripts/10_math.sql.h b/sql/scripts/10_math.sql.h
--- a/sql/scripts/10_math.sql.h
+++ b/sql/scripts/10_math.sql.h
@@ -6,17 +6,5 @@
 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 */
 
-// This file was generated automatically through bootstrap.py.
-// Do not edit this file directly.
-
-#ifndef SQL_10_MATH_H
-#define SQL_10_MATH_H
-
-#include "monetdb_config.h"
-
-#include "gdk.h"
-#include "mal_client.h"
-
-extern str sql_install_10_math(Client c, char *buf, size_t bufsize);
-
-#endif //SQL_10_MATH_H
+// This file was generated automatically with sql2h.py. Do not edit this file 
directly.
+{ "10_math", " CREATE FUNCTION degrees(r double) RETURNS double RETURN 
r*180/pi(); CREATE FUNCTION radians(d double) RETURNS double RETURN d*pi()/180; 
grant execute on function degrees to public; grant execute on function radians 
to public;" }, 
diff --git a/sql/scripts/11_times.sql.h b/sql/scripts/11_times.sql.h
--- a/sql/scripts/11_times.sql.h
+++ b/sql/scripts/11_times.sql.h
@@ -6,17 +6,5 @@
 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 */
 
-// This file was generated automatically through bootstrap.py.
-// Do not edit this file directly.
-
-#ifndef SQL_11_TIMES_H
-#define SQL_11_TIMES_H
-
-#include "monetdb_config.h"
-
-#include "gdk.h"
-#include "mal_client.h"
-
-extern str sql_install_11_times(Client c, char *buf, size_t bufsize);
-
-#endif //SQL_11_TIMES_H
+// This file was generated automatically with sql2h.py. Do not edit this file 
directly.
+{ "11_times", "  create procedure times() external name sql.times; grant 
execute on procedure times to public;" }, 
diff --git a/sql/scripts/12_url.sql.h b/sql/scripts/12_url.sql.h
--- a/sql/scripts/12_url.sql.h
+++ b/sql/scripts/12_url.sql.h
@@ -6,17 +6,5 @@
 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 */
 
-// This file was generated automatically through bootstrap.py.
-// Do not edit this file directly.
-
-#ifndef SQL_12_URL_H
-#define SQL_12_URL_H
-
-#include "monetdb_config.h"
-
-#include "gdk.h"
-#include "mal_client.h"
-
-extern str sql_install_12_url(Client c, char *buf, size_t bufsize);
-
-#endif //SQL_12_URL_H
+// This file was generated automatically with sql2h.py. Do not edit this file 
directly.
+{ "12_url", " CREATE TYPE url EXTERNAL NAME url; CREATE function getAnchor( 
theUrl url ) RETURNS STRING EXTERNAL NAME url.\"getAnchor\"; GRANT EXECUTE ON 
FUNCTION getAnchor(url) TO PUBLIC; CREATE function getBasename(theUrl url) 
RETURNS STRING EXTERNAL NAME url.\"getBasename\"; GRANT EXECUTE ON FUNCTION 
getBasename(url) TO PUBLIC; CREATE function getContent(theUrl url) RETURNS 
STRING EXTERNAL NAME url.\"getContent\"; GRANT EXECUTE ON FUNCTION 
getContent(url) TO PUBLIC; CREATE function getContext(theUrl url) RETURNS 
STRING EXTERNAL NAME url.\"getContext\"; GRANT EXECUTE ON FUNCTION 
getContext(url) TO PUBLIC; CREATE function getDomain(theUrl url) RETURNS STRING 
EXTERNAL NAME url.\"getDomain\"; GRANT EXECUTE ON FUNCTION getDomain(url) TO 
PUBLIC; CREATE function getExtension(theUrl url) RETURNS STRING EXTERNAL NAME 
url.\"getExtension\"; GRANT EXECUTE ON FUNCTION getExtension(url) TO PUBLIC; 
CREATE function getFile(theUrl url) RETURNS STRING EXTERNAL NAME 
url.\"getFile\"; GRANT EXECUTE O
 N FUNCTION getFile(url) TO PUBLIC; CREATE function getHost(theUrl url) RETURNS 
STRING EXTERNAL NAME url.\"getHost\"; GRANT EXECUTE ON FUNCTION getHost(url) TO 
PUBLIC; CREATE function getPort(theUrl url) RETURNS STRING EXTERNAL NAME 
url.\"getPort\"; GRANT EXECUTE ON FUNCTION getPort(url) TO PUBLIC; CREATE 
function getProtocol(theUrl url) RETURNS STRING EXTERNAL NAME 
url.\"getProtocol\"; GRANT EXECUTE ON FUNCTION getProtocol(url) TO PUBLIC; 
CREATE function getQuery(theUrl url) RETURNS STRING EXTERNAL NAME 
url.\"getQuery\"; GRANT EXECUTE ON FUNCTION getQuery(url) TO PUBLIC; CREATE 
function getUser(theUrl url) RETURNS STRING EXTERNAL NAME url.\"getUser\"; 
GRANT EXECUTE ON FUNCTION getUser(url) TO PUBLIC; CREATE function 
getRobotURL(theUrl url) RETURNS STRING EXTERNAL NAME url.\"getRobotURL\"; GRANT 
EXECUTE ON FUNCTION getRobotURL(url) TO PUBLIC; CREATE function isaURL(theUrl 
url) RETURNS BOOL EXTERNAL NAME url.\"isaURL\"; GRANT EXECUTE ON FUNCTION 
isaURL(url) TO PUBLIC; CREATE function 
 newurl(protocol STRING, hostname STRING, \"port\" INT, file STRING) RETURNS 
url EXTERNAL NAME url.\"new\"; GRANT EXECUTE ON FUNCTION newurl(STRING, STRING, 
INT, STRING) TO PUBLIC; CREATE function newurl(protocol STRING, hostname 
STRING, file STRING) RETURNS url EXTERNAL NAME url.\"new\"; GRANT EXECUTE ON 
FUNCTION newurl(STRING, STRING, STRING) TO PUBLIC;" }, 
diff --git a/sql/scripts/13_date.sql.h b/sql/scripts/13_date.sql.h
--- a/sql/scripts/13_date.sql.h
+++ b/sql/scripts/13_date.sql.h
@@ -6,17 +6,5 @@
 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 */
 
-// This file was generated automatically through bootstrap.py.
-// Do not edit this file directly.
-
-#ifndef SQL_13_DATE_H
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to