Changeset: e1bea8928a1b for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e1bea8928a1b Added Files: monetdb5/optimizer/opt_json.c monetdb5/optimizer/opt_json.h Branch: default Log Message:
Add missing files diffs (124 lines): diff --git a/monetdb5/optimizer/opt_json.c b/monetdb5/optimizer/opt_json.c new file mode 100644 --- /dev/null +++ b/monetdb5/optimizer/opt_json.c @@ -0,0 +1,80 @@ +/* + * The contents of this file are subject to the MonetDB Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.monetdb.org/Legal/MonetDBLicense + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is the MonetDB Database System. + * + * The Initial Developer of the Original Code is CWI. + * Portions created by CWI are Copyright (C) 1997-July 2008 CWI. + * Copyright August 2008-2013 MonetDB B.V. + * All Rights Reserved. + * +*/ +/* + * This simple module replaces the SQL rendering with a JSON rendering + * Can be called after dataflow optimizer. The result appears as a string + * in the calling environment. + */ +#include "monetdb_config.h" +#include "mal_builder.h" +#include "opt_json.h" + +int +OPTjsonImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ + int i, j, limit, slimit; + int bu,br,bj; + str nme; + InstrPtr p,q; + int actions = 0; + InstrPtr *old; + + (void) pci; + (void) cntxt; + (void) stk; /* to fool compilers */ + old= mb->stmt; + limit= mb->stop; + slimit = mb->ssize; + if ( newMalBlkStmt(mb,mb->stop) < 0) + return 0; + for (i = 0; i < limit; i++) { + p = old[i]; + if( getModuleId(p) == sqlRef && getFunctionId(p) == affectedRowsRef) { + q = newStmt(mb, jsonRef, resultSetRef); + q = pushArgument(mb, q, bu); + q = pushArgument(mb, q, br); + q = pushArgument(mb, q, bj); + j = getArg(q,j); + p= getInstrPtr(mb,0); + setVarType(mb,getArg(p,0),TYPE_str); + q = newReturnStmt(mb); + getArg(q,0)= getArg(p,0); + pushArgument(mb,q,j); + continue; + } + if( getModuleId(p) == sqlRef && getFunctionId(p) == rsColumnRef) { + nme = getVarConstant(mb,getArg(p,4)).val.sval; + if (strcmp(nme,"uuid")==0) + bu = getArg(p,7); + if (strcmp(nme,"lng")==0) + br = getArg(p,7); + if (strcmp(nme,"json")==0) + bj = getArg(p,7); + freeInstruction(p); + continue; + } + pushInstruction(mb,p); + } + for(; i<slimit; i++) + if (old[i]) + freeInstruction(old[i]); + GDKfree(old); + return actions; +} diff --git a/monetdb5/optimizer/opt_json.h b/monetdb5/optimizer/opt_json.h new file mode 100644 --- /dev/null +++ b/monetdb5/optimizer/opt_json.h @@ -0,0 +1,34 @@ +/* + * The contents of this file are subject to the MonetDB Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.monetdb.org/Legal/MonetDBLicense + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is the MonetDB Database System. + * + * The Initial Developer of the Original Code is CWI. + * Portions created by CWI are Copyright (C) 1997-July 2008 CWI. + * Copyright August 2008-2013 MonetDB B.V. + * All Rights Reserved. +*/ +#ifndef _OPT_JSON_ +#define _OPT_JSON_ +#include "opt_prelude.h" +#include "opt_support.h" +#include "mal_interpreter.h" +#include "mal_instruction.h" +#include "mal_function.h" + +opt_export int OPTjsonImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); + +/* #define _DEBUG_OPT_JSON_ */ +#undef DEBUG_OPT_JSON +#define DEBUG_OPT_JSON 1 +#define OPTDEBUGjson if ( optDebug & (1 <<DEBUG_OPT_JSON) ) + +#endif _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list