Changeset: b31bd6cf23a7 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b31bd6cf23a7
Modified Files:
sql/src/backends/monet5/sql.mx
sql/src/backends/monet5/sql_scenario.mx
sql/src/sql/cluster.sql
Branch: default
Log Message:
sql, cluster: Cleaning the code for keyword clashes.
scenario: handling end of parse of createdb.sql
diffs (130 lines):
diff -r 48881c45a640 -r b31bd6cf23a7 sql/src/backends/monet5/sql.mx
--- a/sql/src/backends/monet5/sql.mx Fri May 14 13:28:56 2010 +0200
+++ b/sql/src/backends/monet5/sql.mx Fri May 14 13:31:05 2010 +0200
@@ -68,6 +68,10 @@
address SQLstatement
comment "Compile and execute a single sql statement (and optionaly send output
on the output stream)";
+pattern include(fname:str):void
+address SQLinclude
+comment "Compile and execute a sql statements on the file";
+
pattern assert(b:bit,msg:str):void
address SQLassert
comment "Generate an exception when b==true";
@@ -793,8 +797,8 @@
return rand := x;
end mmath.rand;
-pattern cluster(sch:str, tbl:str)
-address SQLcluster
+pattern cluster1(sch:str, tbl:str)
+address SQLcluster1
comment "Cluster the columns of a table on the (first) primary key";
pattern cluster2(sch:str, tbl:str)
@@ -1079,7 +1083,7 @@
sql5_export str zero_or_one(ptr ret, int *bid);
sql5_export str not_unique(bit *ret, int *bid);
sql5_export str not_unique_oids(bat *ret, bat *bid);
-sql5_export str SQLcluster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+sql5_export str SQLcluster1(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str SQLnewDictionary(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str SQLdropDictionary(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str SQLgzcompress(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
@@ -4845,7 +4849,7 @@
Initially the first column
@c
-str SQLcluster(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){
+str SQLcluster1(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){
str *sch = (str *) getArgReference(stk,pci,1);
str *tbl = (str *) getArgReference(stk,pci,2);
sql_trans *tr;
diff -r 48881c45a640 -r b31bd6cf23a7 sql/src/backends/monet5/sql_scenario.mx
--- a/sql/src/backends/monet5/sql_scenario.mx Fri May 14 13:28:56 2010 +0200
+++ b/sql/src/backends/monet5/sql_scenario.mx Fri May 14 13:31:05 2010 +0200
@@ -465,7 +465,7 @@
SQLnewcatalog = 0;
snprintf(path,PATHLENGTH,"createdb");
slash_2_dir_sep(path);
- fullname = MSP_locate_script(path);
+ fullname = MSP_locate_sqlscript(path);
if (fullname) {
fd = open_rastream(fullname);
GDKfree(fullname);
@@ -655,7 +655,6 @@
optimize and produce code.
We don;t search the cache for a previous incarnation yet.
@c
-#define _SQL_COMPILE
{
Symbol oldsym= c->curprg;
stmt *s = sql_symbol2stmt(m, m->sym);
@@ -666,7 +665,9 @@
scanner_query_processed(&(m->scanner));
MSinitClientPrg(c,"user",nme);
if (s==0 || (err = mvc_status(m))) {
- msg = createException(PARSE, "SQLparser", "%s",
m->errstr);
+ if ( m->errstr && *m->errstr)
+ msg = createException(PARSE,
"SQLparser", "%s", m->errstr);
+ else msg = MAL_SUCCEED; /* assume end of
parse */
handle_error(m, c->fdout, pstatus);
sqlcleanup(m, err);
/* restore the state */
@@ -755,6 +756,38 @@
*ret= _strdup("SQLcompile");
return msg;
}
+...@-
+Locate a file with SQL commands and execute it. For the time being a 1MB
+file limit is implicitly imposed. If the file can not be located in the
+script library, we assume it is sufficiently self descriptive.
+(Respecting the file system context where the call is executed )
+...@c
+str
+SQLinclude(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ stream *fd;
+ bstream *bfd;
+ str *name = (str *) getArgReference(stk,pci,1);
+ str msg = MAL_SUCCEED, fullname;
+ str *expr;
+
+ fullname= MSP_locate_sqlscript(*name);
+ if ( fullname == NULL)
+ fullname= *name;
+ fd = open_rastream(fullname);
+ if (stream_errnr(fd) == OPEN_ERROR) {
+ stream_destroy(fd);
+ throw(MAL, "sql.include", "could not open file: %s\n", *name);
+ }
+ bfd = bstream_create(fd, 128 * BLOCK);
+ if( bstream_next(bfd) < 0)
+ throw(MAL,"sql.include","could not read %s\n", *name);
+
+ expr = &bfd->buf;
+ msg = SQLstatementIntern(cntxt, expr, "sql.include", TRUE, FALSE);
+ (void) mb;
+ return msg;
+}
@-
The SQL reader collects a (sequence) of statements from the input
diff -r 48881c45a640 -r b31bd6cf23a7 sql/src/sql/cluster.sql
--- a/sql/src/sql/cluster.sql Fri May 14 13:28:56 2010 +0200
+++ b/sql/src/sql/cluster.sql Fri May 14 13:31:05 2010 +0200
@@ -18,8 +18,11 @@
-- For, the oid's are used in join-indices.
-- Clustering of tables may improve IO performance
-create procedure cluster(sys string, tab string)
- external name sql.cluster;
+-- The foreign key constraints should be dropped before
+-- and re-established after the cluster operation.
+
+create procedure cluster1(sys string, tab string)
+ external name sql.cluster1;
create procedure cluster2(sys string, tab string)
external name sql.cluster2;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list