Commit 7faeb631 authored by yiwenshao's avatar yiwenshao Committed by GitHub

Merge pull request #1 from yiwenshao/foreignKey

Foreign key
parents 7e8007ab 30a7d726
......@@ -12,3 +12,8 @@ reset.sql
startMM.sh
test
tutorial-basic.lua
cscope.files
cscope.out
cscope.files
cscope.out
tags
# CryptdbModify
# Newcryptdb
Cryptdb originated from MIT. This is a modified version try to add new features and fix bugs we meet in our environment.
Introduction to the features included will be posted at yiwenshao.github.io.
......@@ -22,3 +22,16 @@ make
If you meet any problems installing it, contact me via shaoyiwenetATgmailDotcom.
new features added
+ set user variable
+ timestamp
+ show create table
obselete functions deleted
+ annotation
find . | grep '\.cc$\|\.c$\|\.h$\|\.hh$' | xargs ctags
rm cscope*
find . | grep '\.cc$\|\.c$\|\.h$\|\.hh$' > cscope.files
cscope -R -b -i cscope.files
......@@ -454,6 +454,9 @@ getLayerKey(const AES_KEY * const mKey, string uniqueFieldName,
if (l == SECLEVEL::DETJOIN) {
return getKey(mKey, "joinjoin", l);
}
if (l == SECLEVEL::OPEFOREIGN){
return getKey(mKey,"foreignjoin",l);
}
return getKey(mKey, uniqueFieldName, l);
}
......
......@@ -7,7 +7,7 @@ CRYPTOOBJ := $(patsubst %.cc,$(OBJDIR)/crypto/%.o,$(CRYPTOSRC))
all: $(OBJDIR)/libedbcrypto.a $(OBJDIR)/libedbcrypto.so
$(OBJDIR)/libedbcrypto.so: $(CRYPTOOBJ) $(OBJDIR)/libedbutil.so
$(CXX) -shared -o $@ $(CRYPTOOBJ) $(LDFLAGS) $(LDRPATH) \
$(CXX) -fPIC -shared -o $@ $(CRYPTOOBJ) $(LDFLAGS) $(LDRPATH) \
-ledbutil -lcrypto -lntl
$(OBJDIR)/libedbcrypto.a: $(CRYPTOOBJ)
......
BasicCrypto.cc
paillier.cc
urandom.cc
arc4.cc
hgd.cc
pbkdf2.cc
ecjoin.cc
ECJoin.cc
search.cc
skip32.cc
ffx.cc
online_ope.cc
mont.cc
prng.cc
ope.cc
SWPSearch.cc
#pragma once
#include <vector>
#include <crypto/hmac.hh>
#include <crypto/arc4.hh>
using std::make_pair;
template<typename T>
class gfe {
public:
......
./mysqlproxy/ConnectWrapper.cc
./main/Connect.hh
./main/metadata_tables.cc
./main/sql_handler.cc
./main/rewrite_field.cc
./main/schema.cc
./main/Analysis.hh
./main/error.cc
./main/dbobject.hh
./main/rewrite_ds.hh
./main/Connect.cc
./main/rewrite_func.cc
./main/dml_handler.hh
./main/CryptoHandlers.cc
./main/dispatcher.hh
./main/dispatcher.cc
./main/error.hh
./main/dml_handler.cc
./main/schema.hh
./main/ddl_handler.hh
./main/stored_procedures.hh
./main/rewrite_main.cc
./main/rewrite_const.cc
./main/rewrite_main.hh
./main/macro_util.hh
./main/Analysis.cc
./main/serializers.hh
./main/rewrite_sum.cc
./main/sql_handler.hh
./main/rewrite_util.hh
./main/metadata_tables.hh
./main/rewrite_ds.cc
./main/MyBack.cc
./main/ddl_handler.cc
./main/alter_sub_handler.cc
./main/stored_procedures.cc
./main/Translator.cc
./main/alter_sub_handler.hh
./main/Translator.hh
./main/CryptoHandlers.hh
./main/rewrite_util.cc
./main/cdb_test.cc
./udf/edb.cc
./util/cryptdb_log.hh
./util/enum_text.hh
./util/params.hh
./util/errstream.hh
./util/ctr.cc
./util/version.hh
./util/cryptdb_log.cc
./util/util.cc
./util/zz.hh
./util/cleanup.hh
./util/ctr.hh
./util/rob.hh
./util/scoped_lock.hh
./util/timer.hh
./util/util.hh
./util/scopedperf.hh
./util/onions.cc
./util/onions.hh
./tt.cpp
./crypto/paillier.hh
./crypto/pbkdf2.cc
./crypto/ffx.cc
./crypto/dj.hh
./crypto/x.cc
./crypto/arc4.cc
./crypto/cbcmac.hh
./crypto/blowfish.hh
./crypto/ec.hh
./crypto/hgd.hh
./crypto/ope-exp.cc
./crypto/sha.hh
./crypto/ffx.hh
./crypto/prng.cc
./crypto/BasicCrypto.hh
./crypto/prng.hh
./crypto/ecjoin.hh
./crypto/ope.cc
./crypto/urandom.cc
./crypto/mont.cc
./crypto/cmc.hh
./crypto/ECJoin.cc
./crypto/online_ope.cc
./crypto/SWPSearch.cc
./crypto/search.hh
./crypto/hgd.cc
./crypto/pbkdf2.hh
./crypto/mont.hh
./crypto/padding.hh
./crypto/cbc.hh
./crypto/bn.hh
./crypto/ECJoin.hh
./crypto/SWPSearch.hh
./crypto/gfe.hh
./crypto/arc4.hh
./crypto/ope.hh
./crypto/skip32.cc
./crypto/skip32.hh
./crypto/search.cc
./crypto/BasicCrypto.cc
./crypto/paillier.cc
./crypto/hmac.hh
./crypto/aes.hh
./crypto/ecjoin.cc
./crypto/online_ope.hh
./obj/util/version.cc
./parser/lex_util.cc
./parser/stringify.hh
./parser/mysql_mods/sql/sql_lex.h
./parser/mysql_mods/sql/lex.h
./parser/mysql_mods/include/mysql_com.h
./parser/mysql_type_metadata.cc
./parser/mysqld-filler.cc
./parser/embedmysql.hh
./parser/sql_utils.hh
./parser/lex_util.hh
./parser/mysql_type_metadata.hh
./parser/sql_utils.cc
./parser/embedmysql.cc
./mysql-src/libmysql/client_settings.h
./mysql-src/libmysql/authentication_win/handshake.cc
./mysql-src/libmysql/authentication_win/log_client.cc
./mysql-src/libmysql/authentication_win/common.cc
./mysql-src/libmysql/authentication_win/handshake.h
./mysql-src/libmysql/authentication_win/plugin_client.cc
./mysql-src/libmysql/authentication_win/handshake_client.cc
./mysql-src/libmysql/authentication_win/common.h
./mysql-src/mysql-test/lib/My/SafeProcess/safe_process_win.cc
./mysql-src/mysql-test/lib/My/SafeProcess/safe_process.cc
./mysql-src/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
./mysql-src/mysys/mysys_priv.h
./mysql-src/mysys/my_static.h
./mysql-src/mysys/my_handler_errors.h
./mysql-src/mysys/my_new.cc
./mysql-src/client/completion_hash.h
./mysql-src/client/sql_string.cc
./mysql-src/client/completion_hash.cc
./mysql-src/client/mysqltest.cc
./mysql-src/client/client_priv.h
./mysql-src/client/mysqlbinlog.cc
./mysql-src/client/mysql.cc
./mysql-src/client/mysqladmin.cc
./mysql-src/client/my_readline.h
./mysql-src/client/sql_string.h
./mysql-src/client/readline.cc
./mysql-src/zlib/trees.h
./mysql-src/zlib/zlib.h
./mysql-src/zlib/crc32.h
./mysql-src/zlib/inffast.h
./mysql-src/zlib/zconf.h
./mysql-src/zlib/deflate.h
./mysql-src/zlib/inffixed.h
./mysql-src/zlib/inflate.h
./mysql-src/zlib/zutil.h
./mysql-src/zlib/inftrees.h
./mysql-src/strings/t_ctype.h
./mysql-src/sql/sql_binlog.cc
./mysql-src/sql/mf_iocache.cc
./mysql-src/sql/item_geofunc.cc
./mysql-src/sql/parse_file.h
./mysql-src/sql/debug_sync.cc
./mysql-src/sql/sql_handler.cc
./mysql-src/sql/sql_db.h
./mysql-src/sql/table.cc
./mysql-src/sql/hash_filo.cc
./mysql-src/sql/sql_error.h
./mysql-src/sql/discover.cc
./mysql-src/sql/sql_view.cc
./mysql-src/sql/sql_plugin.h
./mysql-src/sql/sql_derived.cc
./mysql-src/sql/sql_udf.cc
./mysql-src/sql/sql_partition_admin.h
./mysql-src/sql/sp_cache.h
./mysql-src/sql/spatial.h
./mysql-src/sql/item_row.h
./mysql-src/sql/sql_list.cc
./mysql-src/sql/sql_acl.cc
./mysql-src/sql/sql_admin.cc
./mysql-src/sql/tzfile.h
./mysql-src/sql/sql_signal.cc
./mysql-src/sql/sp_pcontext.cc
./mysql-src/sql/sql_string.cc
./mysql-src/sql/authors.h
./mysql-src/sql/strfunc.cc
./mysql-src/sql/opt_range.h
./mysql-src/sql/log.cc
./mysql-src/sql/sql_locale.cc
./mysql-src/sql/sql_class.cc
./mysql-src/sql/sql_show.h
./mysql-src/sql/sql_load.cc
./mysql-src/sql/sql_load.h
./mysql-src/sql/item_timefunc.cc
./mysql-src/sql/datadict.h
./mysql-src/sql/sql_connect.cc
./mysql-src/sql/sql_parse.cc
./mysql-src/sql/ha_ndbcluster.h
./mysql-src/sql/sql_prepare.h
./mysql-src/sql/sys_vars.h
./mysql-src/sql/transaction.h
./mysql-src/sql/sql_client.cc
./mysql-src/sql/sql_crypt.h
./mysql-src/sql/sp_cache.cc
./mysql-src/sql/sql_rename.h
./mysql-src/sql/rpl_injector.cc
./mysql-src/sql/sql_truncate.cc
./mysql-src/sql/tztime.h
./mysql-src/sql/rpl_handler.h
./mysql-src/sql/rpl_record.cc
./mysql-src/sql/lock.cc
./mysql-src/sql/sp_head.cc
./mysql-src/sql/scheduler.h
./mysql-src/sql/sql_view.h
./mysql-src/sql/sql_admin.h
./mysql-src/sql/item_cmpfunc.cc
./mysql-src/sql/item_row.cc
./mysql-src/sql/repl_failsafe.cc
./mysql-src/sql/nt_servc.cc
./mysql-src/sql/gstream.cc
./mysql-src/sql/rpl_mi.cc
./mysql-src/sql/hostname.cc
./mysql-src/sql/filesort.cc
./mysql-src/sql/thr_malloc.cc
./mysql-src/sql/rpl_reporting.h
./mysql-src/sql/sql_plugin_services.h
./mysql-src/sql/derror.h
./mysql-src/sql/structs.h
./mysql-src/sql/sql_audit.h
./mysql-src/sql/sp.h
./mysql-src/sql/opt_range.cc
./mysql-src/sql/sql_db.cc
./mysql-src/sql/thr_malloc.h
./mysql-src/sql/sql_reload.cc
./mysql-src/sql/sql_base.cc
./mysql-src/sql/sql_repl.h
./mysql-src/sql/main.cc
./mysql-src/sql/records.h
./mysql-src/sql/sql_acl.h
./mysql-src/sql/keycaches.cc
./mysql-src/sql/ha_ndbcluster_cond.h
./mysql-src/sql/sql_const.h
./mysql-src/sql/filesort.h
./mysql-src/sql/rpl_tblmap.h
./mysql-src/sql/sp_head.h
./mysql-src/sql/ha_ndbcluster_binlog.cc
./mysql-src/sql/item_subselect.h
./mysql-src/sql/sp_rcontext.h
./mysql-src/sql/rpl_constants.h
./mysql-src/sql/mysqld.cc
./mysql-src/sql/item_sum.cc
./mysql-src/sql/field.h
./mysql-src/sql/ha_partition.h
./mysql-src/sql/sql_alter.h
./mysql-src/sql/event_db_repository.h
./mysql-src/sql/sql_connect.h
./mysql-src/sql/sql_reload.h
./mysql-src/sql/sql_sort.h
./mysql-src/sql/sql_show.cc
./mysql-src/sql/sha2.cc
./mysql-src/sql/sql_lex.h
./mysql-src/sql/log_event.cc
./mysql-src/sql/rpl_injector.h
./mysql-src/sql/events.h
./mysql-src/sql/sql_tablespace.cc
./mysql-src/sql/sql_manager.cc
./mysql-src/sql/event_parse_data.h
./mysql-src/sql/sql_update.h
./mysql-src/sql/mdl.h
./mysql-src/sql/sql_base.h
./mysql-src/sql/handler.h
./mysql-src/sql/sql_rename.cc
./mysql-src/sql/keycaches.h
./mysql-src/sql/derror.cc
./mysql-src/sql/datadict.cc
./mysql-src/sql/item_strfunc.h
./mysql-src/sql/event_data_objects.cc
./mysql-src/sql/item.h
./mysql-src/sql/sql_select.cc
./mysql-src/sql/sys_vars_shared.h
./mysql-src/sql/ha_partition.cc
./mysql-src/sql/sql_update.cc
./mysql-src/sql/init.cc
./mysql-src/sql/procedure.h
./mysql-src/sql/replication.h
./mysql-src/sql/sql_audit.cc
./mysql-src/sql/field_conv.cc
./mysql-src/sql/partition_info.cc
./mysql-src/sql/rpl_filter.cc
./mysql-src/sql/sql_prepare.cc
./mysql-src/sql/spatial.cc
./mysql-src/sql/sql_delete.h
./mysql-src/sql/sql_time.cc
./mysql-src/sql/sql_parse.h
./mysql-src/sql/sql_hset.h
./mysql-src/sql/sql_signal.h
./mysql-src/sql/sql_trigger.cc
./mysql-src/sql/item_buff.cc
./mysql-src/sql/item_func.cc
./mysql-src/sql/unireg.cc
./mysql-src/sql/rpl_reporting.cc
./mysql-src/sql/client_settings.h
./mysql-src/sql/scheduler.cc
./mysql-src/sql/my_decimal.h
./mysql-src/sql/item_timefunc.h
./mysql-src/sql/rpl_filter.h
./mysql-src/sql/init.h
./mysql-src/sql/item_create.cc
./mysql-src/sql/protocol.h
./mysql-src/sql/event_db_repository.cc
./mysql-src/sql/sql_time.h
./mysql-src/sql/sql_select.h
./mysql-src/sql/sql_profile.h
./mysql-src/sql/event_parse_data.cc
./mysql-src/sql/ha_ndbcluster_tables.h
./mysql-src/sql/sql_delete.cc
./mysql-src/sql/rpl_utility.cc
./mysql-src/sql/sql_cache.h
./mysql-src/sql/sql_bitmap.h
./mysql-src/sql/sql_do.h
./mysql-src/sql/field.cc
./mysql-src/sql/sql_test.cc
./mysql-src/sql/frm_crypt.cc
./mysql-src/sql/sql_table.cc
./mysql-src/sql/nt_servc.h
./mysql-src/sql/sql_insert.h
./mysql-src/sql/events.cc
./mysql-src/sql/custom_conf.h
./mysql-src/sql/des_key_file.h
./mysql-src/sql/sql_help.cc
./mysql-src/sql/parse_file.cc
./mysql-src/sql/sql_derived.h
./mysql-src/sql/rpl_mi.h
./mysql-src/sql/sql_locale.h
./mysql-src/sql/slave.h
./mysql-src/sql/log_event.h
./mysql-src/sql/set_var.cc
./mysql-src/sql/frm_crypt.h
./mysql-src/sql/item_create.h
./mysql-src/sql/log.h
./mysql-src/sql/sql_servers.h
./mysql-src/sql/sql_plugin.cc
./mysql-src/sql/event_scheduler.h
./mysql-src/sql/event_data_objects.h
./mysql-src/sql/sql_partition_admin.cc
./mysql-src/sql/table.h
./mysql-src/sql/hostname.h
./mysql-src/sql/event_queue.cc
./mysql-src/sql/mdl.cc
./mysql-src/sql/lock.h
./mysql-src/sql/rpl_handler.cc
./mysql-src/sql/sys_vars.cc
./mysql-src/sql/sql_list.h
./mysql-src/sql/debug_sync.h
./mysql-src/sql/ha_ndbcluster.cc
./mysql-src/sql/sql_cursor.cc
./mysql-src/sql/slave.cc
./mysql-src/sql/unireg.h
./mysql-src/sql/item_strfunc.cc
./mysql-src/sql/sql_plist.h
./mysql-src/sql/sql_handler.h
./mysql-src/sql/partition_element.h
./mysql-src/sql/item_func.h
./mysql-src/sql/ha_ndbcluster_binlog.h
./mysql-src/sql/sp.cc
./mysql-src/sql/protocol.cc
./mysql-src/sql/sp_rcontext.cc
./mysql-src/sql/sql_tablespace.h
./mysql-src/sql/set_var.h
./mysql-src/sql/sql_partition.h
./mysql-src/sql/sql_crypt.cc
./mysql-src/sql/discover.h
./mysql-src/sql/sql_test.h
./mysql-src/sql/mysqld.h
./mysql-src/sql/sql_partition.cc
./mysql-src/sql/sql_class.h
./mysql-src/sql/sql_help.h
./mysql-src/sql/lex_symbol.h
./mysql-src/sql/sql_priv.h
./mysql-src/sql/partition_info.h
./mysql-src/sql/rpl_record_old.h
./mysql-src/sql/handler.cc
./mysql-src/sql/log_event_old.h
./mysql-src/sql/uniques.cc
./mysql-src/sql/item_cmpfunc.h
./mysql-src/sql/hash_filo.h
./mysql-src/sql/my_decimal.cc
./mysql-src/sql/item_xmlfunc.h
./mysql-src/sql/item_geofunc.h
./mysql-src/sql/sql_binlog.h
./mysql-src/sql/net_serv.cc
./mysql-src/sql/sql_analyse.h
./mysql-src/sql/rpl_utility.h
./mysql-src/sql/sql_cache.cc
./mysql-src/sql/rpl_record_old.cc
./mysql-src/sql/lex.h
./mysql-src/sql/sql_truncate.h
./mysql-src/sql/item_xmlfunc.cc
./mysql-src/sql/sql_analyse.cc
./mysql-src/sql/sql_profile.cc
./mysql-src/sql/message.h
./mysql-src/sql/records.cc
./mysql-src/sql/event_queue.h
./mysql-src/sql/sql_repl.cc
./mysql-src/sql/sql_cursor.h
./mysql-src/sql/sql_string.h
./mysql-src/sql/repl_failsafe.h
./mysql-src/sql/sql_servers.cc
./mysql-src/sql/opt_sum.cc
./mysql-src/sql/sql_union.cc
./mysql-src/sql/log_event_old.cc
./mysql-src/sql/sql_union.h
./mysql-src/sql/strfunc.h
./mysql-src/sql/sql_insert.cc
./mysql-src/sql/rpl_rli.h
./mysql-src/sql/event_scheduler.cc
./mysql-src/sql/sql_lex.cc
./mysql-src/sql/sql_do.cc
./mysql-src/sql/key.h
./mysql-src/sql/ha_ndbcluster_cond.cc
./mysql-src/sql/mysqld_suffix.h
./mysql-src/sql/rpl_tblmap.cc
./mysql-src/sql/sql_alter.cc
./mysql-src/sql/rpl_record.h
./mysql-src/sql/item_sum.h
./mysql-src/sql/item.cc
./mysql-src/sql/sql_manager.h
./mysql-src/sql/gen_lex_hash.cc
./mysql-src/sql/gstream.h
./mysql-src/sql/item_subselect.cc
./mysql-src/sql/procedure.cc
./mysql-src/sql/rpl_rli.cc
./mysql-src/sql/sql_error.cc
./mysql-src/sql/sp_pcontext.h
./mysql-src/sql/sql_callback.h
./mysql-src/sql/transaction.cc
./mysql-src/sql/sql_udf.h
./mysql-src/sql/tztime.cc
./mysql-src/sql/key.cc
./mysql-src/sql/sql_trigger.h
./mysql-src/sql/sql_table.h
./mysql-src/sql/des_key_file.cc
./mysql-src/sql/contributors.h
./mysql-src/sql/sql_array.h
./mysql-src/regex/my_regex.h
./mysql-src/regex/utils.h
./mysql-src/regex/cclass.h
./mysql-src/regex/regex2.h
./mysql-src/regex/cname.h
./mysql-src/cmd-line-utils/libedit/tty.h
./mysql-src/cmd-line-utils/libedit/np/vis.h
./mysql-src/cmd-line-utils/libedit/el_term.h
./mysql-src/cmd-line-utils/libedit/el.h
./mysql-src/cmd-line-utils/libedit/readline/readline.h
./mysql-src/cmd-line-utils/libedit/prompt.h
./mysql-src/cmd-line-utils/libedit/chared.h
./mysql-src/cmd-line-utils/libedit/read.h
./mysql-src/cmd-line-utils/libedit/sig.h
./mysql-src/cmd-line-utils/libedit/sys.h
./mysql-src/cmd-line-utils/libedit/parse.h
./mysql-src/cmd-line-utils/libedit/config.h
./mysql-src/cmd-line-utils/libedit/refresh.h
./mysql-src/cmd-line-utils/libedit/filecomplete.h
./mysql-src/cmd-line-utils/libedit/hist.h
./mysql-src/cmd-line-utils/libedit/search.h
./mysql-src/cmd-line-utils/libedit/histedit.h
./mysql-src/cmd-line-utils/libedit/key.h
./mysql-src/cmd-line-utils/libedit/map.h
./mysql-src/cmd-line-utils/readline/ansi_stdlib.h
./mysql-src/cmd-line-utils/readline/rlwinsize.h
./mysql-src/cmd-line-utils/readline/rlprivate.h
./mysql-src/cmd-line-utils/readline/rlshell.h
./mysql-src/cmd-line-utils/readline/rlstdc.h
./mysql-src/cmd-line-utils/readline/rldefs.h
./mysql-src/cmd-line-utils/readline/config_readline.h
./mysql-src/cmd-line-utils/readline/posixdir.h
./mysql-src/cmd-line-utils/readline/rltty.h
./mysql-src/cmd-line-utils/readline/rltypedefs.h
./mysql-src/cmd-line-utils/readline/xmalloc.h
./mysql-src/cmd-line-utils/readline/history.h
./mysql-src/cmd-line-utils/readline/rlconf.h
./mysql-src/cmd-line-utils/readline/rlmbutil.h
./mysql-src/cmd-line-utils/readline/chardefs.h
./mysql-src/cmd-line-utils/readline/keymaps.h
./mysql-src/cmd-line-utils/readline/histlib.h
./mysql-src/cmd-line-utils/readline/readline.h
./mysql-src/cmd-line-utils/readline/tcap.h
./mysql-src/cmd-line-utils/readline/tilde.h
./mysql-src/cmd-line-utils/readline/posixstat.h
./mysql-src/cmd-line-utils/readline/posixjmp.h
./mysql-src/include/welcome_copyright_notice.h
./mysql-src/include/my_libwrap.h
./mysql-src/include/my_pthread.h
./mysql-src/include/my_alloc.h
./mysql-src/include/rijndael.h
./mysql-src/include/my_tree.h
./mysql-src/include/my_aes.h
./mysql-src/include/hash.h
./mysql-src/include/atomic/nolock.h
./mysql-src/include/atomic/solaris.h
./mysql-src/include/atomic/x86-gcc.h
./mysql-src/include/atomic/generic-msvc.h
./mysql-src/include/atomic/rwlock.h
./mysql-src/include/atomic/gcc_builtins.h
./mysql-src/include/sql_common.h
./mysql-src/include/my_bitmap.h
./mysql-src/include/sslopt-vars.h
./mysql-src/include/mysql_embed.h
./mysql-src/include/mysql_com.h
./mysql-src/include/my_rdtsc.h
./mysql-src/include/myisampack.h
./mysql-src/include/my_net.h
./mysql-src/include/mysql.h
./mysql-src/include/m_ctype.h
./mysql-src/include/m_string.h
./mysql-src/include/my_sys.h
./mysql-src/include/ft_global.h
./mysql-src/include/my_bit.h
./mysql-src/include/myisammrg.h
./mysql-src/include/my_stacktrace.h
./mysql-src/include/my_compare.h
./mysql-src/include/password.h
./mysql-src/include/my_global.h
./mysql-src/include/my_dbug.h
./mysql-src/include/lf.h
./mysql-src/include/heap.h
./mysql-src/include/sha1.h
./mysql-src/include/base64.h
./mysql-src/include/thr_lock.h
./mysql-src/include/my_uctype.h
./mysql-src/include/my_attribute.h
./mysql-src/include/my_getopt.h
./mysql-src/include/sha2.h
./mysql-src/include/my_atomic.h
./mysql-src/include/violite.h
./mysql-src/include/mysys_err.h
./mysql-src/include/my_base.h
./mysql-src/include/typelib.h
./mysql-src/include/my_compiler.h
./mysql-src/include/my_dir.h
./mysql-src/include/my_md5.h
./mysql-src/include/probes_mysql.h
./mysql-src/include/mysql/service_thd_wait.h
./mysql-src/include/mysql/plugin_auth.h
./mysql-src/include/mysql/thread_pool_priv.h
./mysql-src/include/mysql/plugin_ftparser.h
./mysql-src/include/mysql/plugin_auth_common.h
./mysql-src/include/mysql/service_thd_alloc.h
./mysql-src/include/mysql/service_my_snprintf.h
./mysql-src/include/mysql/innodb_priv.h
./mysql-src/include/mysql/plugin_audit.h
./mysql-src/include/mysql/client_plugin.h
./mysql-src/include/mysql/services.h
./mysql-src/include/mysql/plugin.h
./mysql-src/include/mysql/psi/psi.h
./mysql-src/include/mysql/psi/mysql_thread.h
./mysql-src/include/mysql/psi/psi_abi_v1.h
./mysql-src/include/mysql/psi/psi_abi_v2.h
./mysql-src/include/mysql/psi/mysql_file.h
./mysql-src/include/mysql/service_thread_scheduler.h
./mysql-src/include/decimal.h
./mysql-src/include/service_versions.h
./mysql-src/include/errmsg.h
./mysql-src/include/keycache.h
./mysql-src/include/my_time.h
./mysql-src/include/my_list.h
./mysql-src/include/sslopt-longopts.h
./mysql-src/include/myisam.h
./mysql-src/include/my_xml.h
./mysql-src/include/thr_alarm.h
./mysql-src/include/my_alarm.h
./mysql-src/include/queues.h
./mysql-src/include/t_ctype.h
./mysql-src/include/sslopt-case.h
./mysql-src/include/mysql_time.h
./mysql-src/include/my_user.h
./mysql-src/include/probes_mysql_nodtrace.h
./mysql-src/include/my_nosys.h
./mysql-src/extra/yassl/testsuite/testsuite.cpp
./mysql-src/extra/yassl/taocrypt/benchmark/benchmark.cpp
./mysql-src/extra/yassl/taocrypt/test/memory.cpp
./mysql-src/extra/yassl/taocrypt/test/test.cpp
./mysql-src/extra/yassl/taocrypt/src/hash.cpp
./mysql-src/extra/yassl/taocrypt/src/template_instnt.cpp
./mysql-src/extra/yassl/taocrypt/src/twofish.cpp
./mysql-src/extra/yassl/taocrypt/src/md5.cpp
./mysql-src/extra/yassl/taocrypt/src/misc.cpp
./mysql-src/extra/yassl/taocrypt/src/dsa.cpp
./mysql-src/extra/yassl/taocrypt/src/algebra.cpp
./mysql-src/extra/yassl/taocrypt/src/rsa.cpp
./mysql-src/extra/yassl/taocrypt/src/bftables.cpp
./mysql-src/extra/yassl/taocrypt/src/file.cpp
./mysql-src/extra/yassl/taocrypt/src/crypto.cpp
./mysql-src/extra/yassl/taocrypt/src/md4.cpp
./mysql-src/extra/yassl/taocrypt/src/sha.cpp
./mysql-src/extra/yassl/taocrypt/src/ripemd.cpp
./mysql-src/extra/yassl/taocrypt/src/coding.cpp
./mysql-src/extra/yassl/taocrypt/src/random.cpp
./mysql-src/extra/yassl/taocrypt/src/blowfish.cpp
./mysql-src/extra/yassl/taocrypt/src/arc4.cpp
./mysql-src/extra/yassl/taocrypt/src/integer.cpp
./mysql-src/extra/yassl/taocrypt/src/des.cpp
./mysql-src/extra/yassl/taocrypt/src/asn.cpp
./mysql-src/extra/yassl/taocrypt/src/aes.cpp
./mysql-src/extra/yassl/taocrypt/src/tftables.cpp
./mysql-src/extra/yassl/taocrypt/src/aestables.cpp
./mysql-src/extra/yassl/taocrypt/src/dh.cpp
./mysql-src/extra/yassl/taocrypt/src/md2.cpp
./mysql-src/extra/yassl/src/yassl.cpp
./mysql-src/extra/yassl/src/template_instnt.cpp
./mysql-src/extra/yassl/src/yassl_error.cpp
./mysql-src/extra/yassl/src/cert_wrapper.cpp
./mysql-src/extra/yassl/src/timer.cpp
./mysql-src/extra/yassl/src/log.cpp
./mysql-src/extra/yassl/src/yassl_imp.cpp
./mysql-src/extra/yassl/src/ssl.cpp
./mysql-src/extra/yassl/src/buffer.cpp
./mysql-src/extra/yassl/src/socket_wrapper.cpp
./mysql-src/extra/yassl/src/dummy.cpp
./mysql-src/extra/yassl/src/handshake.cpp
./mysql-src/extra/yassl/src/lock.cpp
./mysql-src/extra/yassl/src/yassl_int.cpp
./mysql-src/extra/yassl/src/crypto_wrapper.cpp
./mysql-src/extra/yassl/include/openssl/objects.h
./mysql-src/extra/yassl/include/openssl/hmac.h
./mysql-src/extra/yassl/include/openssl/md5.h
./mysql-src/extra/yassl/include/openssl/md4.h
./mysql-src/extra/yassl/include/openssl/prefix_crypto.h
./mysql-src/extra/yassl/include/openssl/rand.h
./mysql-src/extra/yassl/include/openssl/evp.h
./mysql-src/extra/yassl/include/openssl/x509.h
./mysql-src/extra/yassl/include/openssl/x509v3.h
./mysql-src/extra/yassl/include/openssl/lhash.h
./mysql-src/extra/yassl/include/openssl/des_old.h
./mysql-src/extra/yassl/include/openssl/ssl.h
./mysql-src/extra/yassl/include/openssl/engine.h
./mysql-src/extra/yassl/include/openssl/pkcs12.h
./mysql-src/extra/yassl/include/openssl/crypto.h
./mysql-src/extra/yassl/include/openssl/des.h
./mysql-src/extra/yassl/include/openssl/pem.h
./mysql-src/extra/yassl/include/openssl/prefix_ssl.h
./mysql-src/extra/yassl/include/openssl/opensslv.h
./mysql-src/extra/yassl/include/openssl/rsa.h
./mysql-src/extra/yassl/include/openssl/err.h
./mysql-src/extra/yassl/include/openssl/sha.h
./mysql-src/extra/yassl/examples/echoserver/echoserver.cpp
./mysql-src/extra/yassl/examples/client/client.cpp
./mysql-src/extra/yassl/examples/server/server.cpp
./mysql-src/extra/yassl/examples/echoclient/echoclient.cpp
./mysql-src/libmysqld/embedded_priv.h
./mysql-src/libmysqld/emb_qcache.h
./mysql-src/libmysqld/emb_qcache.cc
./mysql-src/libmysqld/resource.h
./mysql-src/libmysqld/examples/builder-sample/emb_samples.cpp
./mysql-src/libmysqld/examples/builder-sample/emb_samples.h
./mysql-src/libmysqld/examples/builder-sample/emb_sample.cpp
./mysql-src/libmysqld/lib_sql.cc
./mysql-src/packaging/WiX/ca/CustomAction.cpp
./mysql-src/vio/vio_priv.h
./mysql-src/vio/viotest-sslconnect.cc
./mysql-src/vio/viotest.cc
./mysql-src/build/libmysql/libmysql_exports_file.cc
./mysql-src/build/sql/sql_builtin.cc
./mysql-src/build/sql/sql_yacc.h
./mysql-src/build/sql/sql_yacc.cc
./mysql-src/build/sql/lex_hash.h
./mysql-src/build/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp
./mysql-src/build/cmd-line-utils/libedit/help.h
./mysql-src/build/cmd-line-utils/libedit/vi.h
./mysql-src/build/cmd-line-utils/libedit/fcns.h
./mysql-src/build/cmd-line-utils/libedit/common.h
./mysql-src/build/cmd-line-utils/libedit/emacs.h
./mysql-src/build/include/mysqld_error.h
./mysql-src/build/include/sql_state.h
./mysql-src/build/include/mysqld_ername.h
./mysql-src/build/include/config.h
./mysql-src/build/include/mysql_version.h
./mysql-src/build/include/my_config.h
This source diff could not be displayed because it is too large. You can view the blob instead.
sudo gdb ./obj/main/cdb_test `ps aux| grep cdb_test|grep -v grep|awk '{print $2}'`
###start gdb
sudo gdb `which mysql-proxy` `ps aux | grep 'mysql-proxy.cnf' |grep -v grep | awk '{print $2}'`
......@@ -208,7 +208,6 @@ needsSalt(OLK olk)
bool
needsSalt(EncSet es)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (auto pair : es.osl) {
OLK olk(pair.first, pair.second.first, pair.second.second);
if (needsSalt(olk)) {
......@@ -228,23 +227,6 @@ operator<<(std::ostream &out, const reason &r)
return out;
}
/*
void
RewritePlan::restrict(const EncSet & es) {
es_out = es_out.intersect(es);
assert_s(!es_out.empty(), "after restrict rewrite plan has empty encset");
if (plan.size()) { //node has children
for (auto pair = plan.begin(); pair != plan.end(); pair++) {
if (!es.contains(pair->first)) {
plan.erase(pair);
}
}
}
}
*/
std::ostream&
operator<<(std::ostream &out, const RewritePlan * const rp)
{
......@@ -313,7 +295,7 @@ dropAll(const std::unique_ptr<Connect> &conn)
std::vector<std::string>
getAllUDFs()
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
//std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::vector<std::string> udfs;
for (const udf_func * const u: udf_list) {
std::stringstream ss;
......@@ -328,11 +310,11 @@ getAllUDFs()
ss << " SONAME 'edb.so';";
udfs.push_back(ss.str());
}
std::cout<<"all udfs:"<<std::endl;
for(std::string s:udfs){
std::cout<<s<<"\t";
}
std::cout<<std::endl;
return udfs;
}
......@@ -388,12 +370,10 @@ SharedProxyState::SharedProxyState(ConnectionInfo ci,
cache(std::move(SchemaCache()))
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// make sure the server was not started in SQL_SAFE_UPDATES mode
// > it might not even be possible to start the server in this mode;
// better to be safe
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::unique_ptr<DBResult> dbres;
assert(conn->execute("SELECT @@sql_safe_updates", &dbres));
assert(1 == mysql_num_rows(dbres->n));
......@@ -677,14 +657,14 @@ deltaOutputBeforeQuery(const std::unique_ptr<Connect> &e_conn,
CompletionType completion_type,
uint64_t *const embedded_completion_id)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string &escaped_original_query =
escapeString(e_conn, original_query);
const std::string &escaped_rewritten_query =
escapeString(e_conn, rewritten_query);
std::cout<<"escaped_original_query: "<<escaped_original_query<<"\n"<<"original_query: "<<
original_query<<"\n"<<"escaped_rewritten_query: "<<escaped_rewritten_query<<"\n"<<"rewritten_query: "<<
rewritten_query<<std::endl;
RFIF(escaped_original_query.length() <= STORED_QUERY_LENGTH
&& escaped_rewritten_query.length() <= STORED_QUERY_LENGTH);
......@@ -719,7 +699,7 @@ deltaOutputAfterQuery(const std::unique_ptr<Connect> &e_conn,
const std::vector<std::unique_ptr<Delta> > &deltas,
uint64_t embedded_completion_id)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
RFIF(e_conn->execute("START TRANSACTION;"));
const std::string q_update =
......@@ -740,7 +720,7 @@ static bool
tableCopy(const std::unique_ptr<Connect> &c, const std::string &src,
const std::string &dest)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string delete_query =
" DELETE FROM " + dest + ";";
RETURN_FALSE_IF_FALSE(c->execute(delete_query));
......@@ -756,7 +736,7 @@ tableCopy(const std::unique_ptr<Connect> &c, const std::string &src,
bool
setRegularTableToBleedingTable(const std::unique_ptr<Connect> &e_conn)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string src = MetaData::Table::bleedingMetaObject();
const std::string dest = MetaData::Table::metaObject();
return tableCopy(e_conn, src, dest);
......@@ -765,7 +745,7 @@ setRegularTableToBleedingTable(const std::unique_ptr<Connect> &e_conn)
bool
setBleedingTableToRegularTable(const std::unique_ptr<Connect> &e_conn)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string src = MetaData::Table::metaObject();
const std::string dest = MetaData::Table::bleedingMetaObject();
return tableCopy(e_conn, src, dest);
......@@ -775,7 +755,7 @@ bool Analysis::addAlias(const std::string &alias,
const std::string &db,
const std::string &table)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
auto db_alias_pair = table_aliases.find(db);
if (table_aliases.end() == db_alias_pair) {
table_aliases.insert(
......@@ -799,36 +779,48 @@ OnionMeta &Analysis::getOnionMeta(const std::string &db,
const std::string &field,
onion o) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return this->getOnionMeta(this->getFieldMeta(db, table, field), o);
}
OnionMeta &Analysis::getOnionMeta(const FieldMeta &fm,
onion o) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
OnionMeta *const om = fm.getOnionMeta(o);
TEST_IdentifierNotFound(om, TypeText<onion>::toText(o));
//TEST_IdentifierNotFound(om, TypeText<onion>::toText(o));
return *om;
}
OnionMeta *Analysis::getOnionMeta2(const FieldMeta &fm,
onion o) const
{
OnionMeta *const om = fm.getOnionMeta(o);
//TEST_IdentifierNotFound(om, TypeText<onion>::toText(o));
return om;
}
OnionMeta *Analysis::getOnionMeta2(const std::string &db,
const std::string &table,
const std::string &field,
onion o) const
{
return this->getOnionMeta2(this->getFieldMeta(db, table, field), o);
}
FieldMeta &Analysis::getFieldMeta(const std::string &db,
const std::string &table,
const std::string &field) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
FieldMeta * const fm =
this->getTableMeta(db, table).getChild(IdentityMetaKey(field));
TEST_IdentifierNotFound(fm, field);
return *fm;
}
FieldMeta &Analysis::getFieldMeta(const TableMeta &tm,
const std::string &field) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
FieldMeta *const fm = tm.getChild(IdentityMetaKey(field));
TEST_IdentifierNotFound(fm, field);
......@@ -838,7 +830,6 @@ FieldMeta &Analysis::getFieldMeta(const TableMeta &tm,
TableMeta &Analysis::getTableMeta(const std::string &db,
const std::string &table) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const DatabaseMeta &dm = this->getDatabaseMeta(db);
TableMeta *const tm =
......@@ -851,7 +842,6 @@ TableMeta &Analysis::getTableMeta(const std::string &db,
DatabaseMeta &
Analysis::getDatabaseMeta(const std::string &db) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
DatabaseMeta *const dm = this->schema.getChild(IdentityMetaKey(db));
TEST_DatabaseNotFound(dm, db);
......@@ -861,14 +851,12 @@ Analysis::getDatabaseMeta(const std::string &db) const
bool Analysis::tableMetaExists(const std::string &db,
const std::string &table) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return this->nonAliasTableMetaExists(db, unAliasTable(db, table));
}
bool Analysis::nonAliasTableMetaExists(const std::string &db,
const std::string &table) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const DatabaseMeta &dm = this->getDatabaseMeta(db);
return dm.childExists(IdentityMetaKey(table));
}
......@@ -877,7 +865,6 @@ bool Analysis::nonAliasTableMetaExists(const std::string &db,
bool
Analysis::databaseMetaExists(const std::string &db) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return this->schema.childExists(IdentityMetaKey(db));
}
......@@ -885,7 +872,6 @@ std::string Analysis::getAnonTableName(const std::string &db,
const std::string &table,
bool *const is_alias) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// tell the caller if you are giving him an alias
if (is_alias) {
*is_alias = this->isAlias(db, table);
......@@ -903,7 +889,6 @@ Analysis::translateNonAliasPlainToAnonTableName(const std::string &db,
const std::string &table)
const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
TableMeta *const tm =
this->getDatabaseMeta(db).getChild(IdentityMetaKey(table));
TEST_IdentifierNotFound(tm, table);
......@@ -942,7 +927,6 @@ bool Analysis::isAlias(const std::string &db,
std::string Analysis::unAliasTable(const std::string &db,
const std::string &table) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
auto db_alias_pair = table_aliases.find(db);
if (table_aliases.end() == db_alias_pair) {
return table;
......
......@@ -300,15 +300,24 @@ public:
OnionMeta &getOnionMeta(const std::string &db,
const std::string &table,
const std::string &field, onion o) const;
OnionMeta* getOnionMeta2(const std::string &db,
const std::string &table,
const std::string &field, onion o) const;
OnionMeta &getOnionMeta(const FieldMeta &fm, onion o) const;
OnionMeta* getOnionMeta2(const FieldMeta &fm, onion o) const;
FieldMeta &getFieldMeta(const std::string &db,
const std::string &table,
const std::string &field) const;
FieldMeta &getFieldMeta(const TableMeta &tm,
const std::string &field) const;
TableMeta &getTableMeta(const std::string &db,
const std::string &table) const;
DatabaseMeta &getDatabaseMeta(const std::string &db) const;
bool tableMetaExists(const std::string &db,
const std::string &table) const;
bool nonAliasTableMetaExists(const std::string &db,
......@@ -317,10 +326,12 @@ public:
std::string getAnonTableName(const std::string &db,
const std::string &table,
bool *const is_alias=NULL) const;
std::string
translateNonAliasPlainToAnonTableName(const std::string &db,
const std::string &table)
const;
std::string getAnonIndexName(const std::string &db,
const std::string &table,
const std::string &index_name,
......@@ -328,16 +339,20 @@ public:
std::string getAnonIndexName(const TableMeta &tm,
const std::string &index_name,
onion o) const;
static const EncLayer &getBackEncLayer(const OnionMeta &om);
static SECLEVEL getOnionLevel(const OnionMeta &om);
SECLEVEL getOnionLevel(const FieldMeta &fm, onion o);
static const std::vector<std::unique_ptr<EncLayer> > &
getEncLayers(const OnionMeta &om);
const SchemaInfo &getSchema() const {return schema;}
std::vector<std::unique_ptr<Delta> > deltas;
std::string getDatabaseName() const {return db_name;}
const std::unique_ptr<AES_KEY> &getMasterKey() const {return master_key;}
SECURITY_RATING getDefaultSecurityRating() const
{return default_sec_rating;}
......
......@@ -111,6 +111,17 @@ public:
deserialize(unsigned int id, const SerialLayer &serial);
};
class OPEFOREIGNFactory : public LayerFactory {
public:
static std::unique_ptr<EncLayer>
create(const Create_field &cf, const std::string &key);
static std::unique_ptr<EncLayer>
deserialize(unsigned int id, const SerialLayer &serial);
};
class HOMFactory : public LayerFactory {
public:
......@@ -158,6 +169,7 @@ EncLayerFactory::encLayer(onion o, SECLEVEL sl, const Create_field &cf,
case SECLEVEL::DET: {return DETFactory::create(cf, key);}
case SECLEVEL::DETJOIN: {return DETJOINFactory::create(cf, key);}
case SECLEVEL::OPE:{return OPEFactory::create(cf, key);}
case SECLEVEL::OPEFOREIGN:{return OPEFOREIGNFactory::create(cf,key);}
case SECLEVEL::HOM: {return HOMFactory::create(cf, key);}
case SECLEVEL::SEARCH: {
return std::unique_ptr<EncLayer>(new Search(cf, key));
......@@ -171,6 +183,7 @@ EncLayerFactory::encLayer(onion o, SECLEVEL sl, const Create_field &cf,
FAIL_TextMessageError("unknown or unimplemented security level");
}
//recover from the database using lambda.
std::unique_ptr<EncLayer>
EncLayerFactory::deserializeLayer(unsigned int id,
const std::string &serial)
......@@ -188,6 +201,9 @@ EncLayerFactory::deserializeLayer(unsigned int id,
case SECLEVEL::DETJOIN:
return DETJOINFactory::deserialize(id, li);
case SECLEVEL::OPEFOREIGN:
return OPEFOREIGNFactory::deserialize(id,li);
case SECLEVEL::OPE:
return OPEFactory::deserialize(id, li);
......@@ -312,6 +328,8 @@ private:
const std::pair<int64_t, uint64_t> inclusiveRange;
};
static CryptedInteger
overrideCreateFieldCryptedIntegerFactory(const Create_field &cf,
const std::string &key,
......@@ -1036,6 +1054,18 @@ private:
mutable OPE ope; // HACK
};
class OPEFOREIGN_int:public OPE_int{
public:
OPEFOREIGN_int(const Create_field &cf, const std::string &seed_key):OPE_int(cf,seed_key){}
OPEFOREIGN_int(unsigned int id, const CryptedInteger &cinteger,
size_t plain_size, size_t ciph_size):OPE_int(id,cinteger,plain_size,ciph_size){}
SECLEVEL level() const {return SECLEVEL::OPEFOREIGN;}
std::string name() const {return "OPEFOREIGN_int";}
static std::unique_ptr<OPEFOREIGN_int>
deserialize(unsigned int id, const std::string &serial);
};
class OPE_str : public EncLayer {
public:
OPE_str(const Create_field &cf, const std::string &seed_key);
......@@ -1063,6 +1093,17 @@ private:
static const size_t ciph_size = 8;
};
class OPEFOREIGN_str: public OPE_str{
public:
OPEFOREIGN_str(const Create_field &cf, const std::string &seed_key):OPE_str(cf,seed_key){}
OPEFOREIGN_str(unsigned int id, const std::string &serial):OPE_str(id,serial){}
SECLEVEL level() const {return SECLEVEL::OPEFOREIGN;}
std::string name() const {return "OPEFOREIGN_str";}
};
std::unique_ptr<EncLayer>
OPEFactory::create(const Create_field &cf, const std::string &key)
{
......@@ -1088,6 +1129,35 @@ OPEFactory::deserialize(unsigned int id, const SerialLayer &sl)
}
}
std::unique_ptr<EncLayer>
OPEFOREIGNFactory::create(const Create_field &cf, const std::string &key) {
if (isMySQLTypeNumeric(cf)) {
if (cf.sql_type == MYSQL_TYPE_DECIMAL
|| cf.sql_type == MYSQL_TYPE_NEWDECIMAL) {
FAIL_TextMessageError("decimal support is broken");
}
return std::unique_ptr<EncLayer>(new OPEFOREIGN_int(cf, key));
}
return std::unique_ptr<EncLayer>(new OPEFOREIGN_str(cf, key));
}
std::unique_ptr<EncLayer>
OPEFOREIGNFactory::deserialize(unsigned int id, const SerialLayer &sl)
{
if (sl.name == "OPEFOREIGN_int") {
return OPEFOREIGN_int::deserialize(id, sl.layer_info);
} else if (sl.name == "OPEFOREIGN_str") {
return std::unique_ptr<EncLayer>(new OPEFOREIGN_str(id, sl.layer_info));
} else {
FAIL_TextMessageError("decimal support broken");
}
}
static size_t
toMultiple(size_t n, size_t multiple)
{
......@@ -1171,9 +1241,22 @@ OPE_int::deserialize(unsigned int id, const std::string &serial)
const size_t ciph_bytes = strtoul_(vec[1]);
const CryptedInteger cint = CryptedInteger::deserialize(vec[2]);
return std::unique_ptr<OPE_int>(new OPE_int(id, cint, plain_bytes,
ciph_bytes) );
}
std::unique_ptr<OPEFOREIGN_int>
OPEFOREIGN_int::deserialize(unsigned int id, const std::string &serial)
{
const std::vector<std::string> vec = unserialize_string(serial);
const size_t plain_bytes = strtoul_(vec[0]);
const size_t ciph_bytes = strtoul_(vec[1]);
const CryptedInteger cint = CryptedInteger::deserialize(vec[2]);
return std::unique_ptr<OPEFOREIGN_int>(new OPEFOREIGN_int(id, cint, plain_bytes,
ciph_bytes));
}
std::string
OPE_int::doSerialize() const
{
......@@ -1375,9 +1458,10 @@ HOM::newCreateField(const Create_field &cf,
&my_charset_bin);
}
//if first, use seed key to generate
void
HOM::unwait() const
{
HOM::unwait() const {
const std::unique_ptr<streamrng<arc4>>
prng(new streamrng<arc4>(seed_key));
sk = new Paillier_priv(Paillier_priv::keygen(prng.get(), nbits));
......
......@@ -177,3 +177,10 @@ public:
std::string doSerialize() const;
};
......@@ -7,7 +7,7 @@ CRYPTDB_SRCS := schema.cc Translator.cc Connect.cc \
rewrite_func.cc rewrite_sum.cc metadata_tables.cc \
error.cc stored_procedures.cc rewrite_ds.cc rewrite_main.cc
CRYPTDB_PROGS:= cdb_test MyBack
CRYPTDB_PROGS:=
CRYPTDBPROGOBJS := $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS))
......@@ -27,7 +27,7 @@ $(OBJDIR)/libcryptdb.so: $(CRYPTDB_OBJS) \
$(OBJDIR)/libedbcrypto.so \
$(OBJDIR)/libedbutil.so \
$(OBJDIR)/libedbparser.so
$(CXX) -shared -o $@ $(CRYPTDB_OBJS) $(LDFLAGS) $(LDRPATH) \
$(CXX) -shared -g -o $@ $(CRYPTDB_OBJS) $(LDFLAGS) $(LDRPATH) \
-ledbcrypto -ledbutil -ledbparser -lntl -lcrypto
install: install_main
......
......@@ -108,28 +108,125 @@ class ChangeColumnSubHandler : public AlterSubHandler {
}
};
class ForeignKeySubHandler : public AlterSubHandler {
virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const
{
FAIL_TextMessageError("implement ForeignKeySubHandler");
}
};
LEX * ForeignKeySubHandler::rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const{
// LEX *const new_lex = copyWithTHD(lex);
TableMeta const &ctm =
a.getTableMeta(preamble.dbname, preamble.table);
//find essential information from froeign key
auto it =
List_iterator<Key>(lex->alter_info.key_list);
while(auto cur = it++){
if(cur->type==Key::FOREIGN_KEY){
Table_ident* ref_table = ((Foreign_key*)cur)->ref_table;
std::string ref_table_name = convert_lex_str(ref_table->table);
TableMeta const &reftm =
a.getTableMeta(preamble.dbname, ref_table_name);
auto it_ref_columns = List_iterator<Key_part_spec>(((Foreign_key*)cur)->ref_columns);
//should find Only ope, and adjust it to OPEFOREIGN
while(auto cur_ref_columns=it_ref_columns++){
std::string ref_column_name = convert_lex_str(cur_ref_columns->field_name);
OnionMeta *om = a.getOnionMeta2(preamble.dbname,ref_table_name,ref_column_name,oOPE);
FieldMeta &reffm = a.getFieldMeta(reftm,ref_column_name);
assert(om!=NULL);
if(om->getLayerBack()->level()==SECLEVEL::RND||
om->getLayerBack()->level()==SECLEVEL::OPE){
OnionAdjustExcept oje(reftm,reffm,oOPE,SECLEVEL::OPEFOREIGN);
throw oje;
}else if(om->getLayerBack()->level()==SECLEVEL::OPEFOREIGN){
//nothing here
}else{
assert(0);
}
}
}else if(cur->type==Key::MULTIPLE){//adjust to OPEFROEIGN
auto it_columns = List_iterator<Key_part_spec>(cur->columns);
while(auto go = it_columns++){
std::string current_field_name = convert_lex_str(go->field_name);
OnionMeta *om = a.getOnionMeta2(preamble.dbname, preamble.table, current_field_name, oOPE);
if(om!=NULL){
if(om->getLayerBack()->level()==SECLEVEL::RND||
om->getLayerBack()->level()==SECLEVEL::OPE){
const FieldMeta &fm = a.getFieldMeta(ctm,current_field_name);
OnionAdjustExcept oje(ctm,fm,oOPE,SECLEVEL::OPEFOREIGN);
throw oje;
}else if(om->getLayerBack()->level()==SECLEVEL::OPEFOREIGN){
//nothing
}else{
assert(0);
}
}
}
}else{
assert(0);
return NULL;
}
}
highLevelRewriteKey(ctm, *lex, lex, a);
highLevelRewriteForeignKey(ctm,*lex,lex,a,preamble.table);
return lex;
}
class AddIndexSubHandler : public AlterSubHandler {
virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const
{
LEX * AddIndexSubHandler::rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)const{
if(lex->alter_info.flags & ALTER_FOREIGN_KEY) return lex;
//LEX *const new_lex = copyWithTHD(lex);
TableMeta const &tm =
a.getTableMeta(preamble.dbname, preamble.table);
//before rewriting key, we should check the layers of the onions for each field
auto it =
List_iterator<Key>(lex->alter_info.key_list);
while(auto cur = it++){
//for each key, find the columns
switch(cur->type){
case Key::PRIMARY:
case Key::UNIQUE:
case Key::MULTIPLE:
case Key::FULLTEXT:
case Key::SPATIAL:{
//for each column, find the
auto it_columns = List_iterator<Key_part_spec>(cur->columns);
while(auto go = it_columns++){
std::string current_field_name = convert_lex_str(go->field_name);
OnionMeta *om = a.getOnionMeta2(preamble.dbname, preamble.table, current_field_name, oDET);
if(om!=NULL){
//Remove RND here(reference rewrite_field.cc)
if(om->getLayerBack()->level()==SECLEVEL::RND){
const TableMeta &tm = a.getTableMeta(preamble.dbname,preamble.table);
const FieldMeta &fm = a.getFieldMeta(tm,current_field_name);
OnionAdjustExcept oje(tm,fm,oDET,SECLEVEL::DET);
throw oje;
}
}
om = a.getOnionMeta2(preamble.dbname,preamble.table,convert_lex_str(go->field_name),oOPE);
if(om!=NULL){
//Still remove RND here
if(om->getLayerBack()->level()==SECLEVEL::RND){
const TableMeta &tm = a.getTableMeta(preamble.dbname,preamble.table);
const FieldMeta &fm = a.getFieldMeta(tm,current_field_name);
OnionAdjustExcept oje(tm,fm,oOPE,SECLEVEL::OPE);
throw oje;
}
}
}
break;
}
case Key::FOREIGN_KEY:{
//assert(0);
//do nothing here
}
}
}
//if we have foreign, then no need to rewrite here
highLevelRewriteKey(tm, *lex, lex, a);
return lex;
}
};
}
class DropIndexSubHandler : public AlterSubHandler {
virtual LEX *
......@@ -214,7 +311,6 @@ class DisableOrEnableKeys : public AlterSubHandler {
LEX *AlterSubHandler::
transformLex(Analysis &a, LEX *const lex) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string &db = lex->select_lex.table_list.first->db;
TEST_DatabaseDiscrepancy(db, a.getDatabaseName());
const Preamble preamble(db,
......
......@@ -21,5 +21,24 @@ protected:
AlterSubHandler() {;}
};
class AddIndexSubHandler : public AlterSubHandler {
virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)const;
};
class ForeignKeySubHandler : public AlterSubHandler{
virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)const;
};
class AlterDispatcher;
AlterDispatcher *buildAlterSubDispatcher();
......@@ -46,6 +46,8 @@
FILE* fr,*fw;
static std::string embeddedDir="/t/cryt/shadow";
//My WrapperState.
......@@ -94,6 +96,7 @@ struct rawReturnValue{
};
struct backupOnionSelection {
int numOfFields;
std::vector<int> fieldSize;
......@@ -375,7 +378,6 @@ static void processTableMeta(const TableMeta &table){
static void processDatabaseMeta(const DatabaseMeta & db) {
std::cout<<GREEN_BEGIN<<"PRINT DatabaseMeta"<<COLOR_END<<std::endl;
for(const auto & table: db.getChildren()){
// std::cout<<table.second->getDatabaseID()<<":"<<table.first.getValue()<<std::endl;
processTableMeta(*(table.second));
}
}
......@@ -889,17 +891,24 @@ main() {
std::getline(std::cin,curQuery);
continue;
}
if(curQuery=="back"){
startBack();
}else{
std::cout<<GREEN_BEGIN<<"curQuery: "<<curQuery<<"\n"<<COLOR_END<<std::endl;
batchTogether(client,curQuery,_thread_id);
}
/*
if(curQuery=="back"){
startBack();
}else{
std::cout<<GREEN_BEGIN<<"curQuery: "<<curQuery<<"\n"<<COLOR_END<<std::endl;
batchTogether(client,curQuery,_thread_id);
}*/
std::unique_ptr<SchemaInfo> schema = myLoadSchemaInfo();
processSchemaInfo(*schema);
std::cout<<GREEN_BEGIN<<"\nplease input a new query:#######"<<COLOR_END<<std::endl;
std::getline(std::cin,curQuery);
}
fclose(fr);
fclose(fw);
return 0;
......
......@@ -11,9 +11,12 @@
#include <util/yield.hpp>
class CreateTableHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const
//a list of ddl handlers, buildddlhandler, and ddlexecutor
//################################################################Create table handler#########################################################################################
AbstractQueryExecutor *
CreateTableHandler::rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const
{
assert(a.deltas.size() == 0);
......@@ -60,7 +63,7 @@ class CreateTableHandler : public DDLHandler {
TABLE_LIST *const tbl =
rewrite_table_list(new_lex->select_lex.table_list.first,
tm->getAnonTableName());
//new table_list only contain one element
new_lex->select_lex.table_list =
*oneElemListWithTHD<TABLE_LIST>(tbl);
......@@ -75,6 +78,7 @@ class CreateTableHandler : public DDLHandler {
//对现有的每个field, 如id,name, 都在内部通过createAndRewriteField函数扩展成多个洋葱+salt.
//其中洋葱有多个层, 其通过newCreateField函数, 决定了类型, 而新的field的名字, 就是洋葱的名字传过去的.
//扩展以后, 就是新的Create_field类型了, 这了返回的list是被继续传到引用参数里面的, 很奇怪的用法.
//key data在这里的作用是, 决定是不是unique, 从而选择和是的洋葱层次.
new_lex->alter_info.create_list =
accumList<Create_field>(it,
[&a, &tm, &key_data] (List<Create_field> out_list,
......@@ -82,12 +86,11 @@ class CreateTableHandler : public DDLHandler {
return createAndRewriteField(a, cf, tm.get(),
true, key_data, out_list);
});
// -----------------------------
// Rewrite INDEX
// -----------------------------
highLevelRewriteKey(*tm.get(), *lex, new_lex, a);
highLevelRewriteForeignKey(*tm.get(), *lex, new_lex, a,pre.table);
// -----------------------------
// Update TABLE
// -----------------------------
......@@ -97,37 +100,23 @@ class CreateTableHandler : public DDLHandler {
a.getDatabaseMeta(pre.dbname),
IdentityMetaKey(pre.table))));
} else { // Table already exists.
// Make sure we aren't trying to create a table that
// already exists.
const bool test =
lex->create_info.options & HA_LEX_CREATE_IF_NOT_EXISTS;
TEST_TextMessageError(test,
"Table " + pre.table + " already exists!");
//why still rewrite here???
// -----------------------------
// Rewrite TABLE
// -----------------------------
//这部分在exists的时候, 没有被执行!!!,但是如何抛出一场返回给客户端信息呢?
new_lex->select_lex.table_list =
rewrite_table_list(lex->select_lex.table_list, a);
// > We do not rewrite the fields because presumably the caller
// can do a CREATE TABLE IF NOT EXISTS for a table that already
// exists, but with fields that do not actually exist.
// > This would cause problems when trying to look up FieldMeta
// for these non-existant fields.
// > We may want to do some additional non-deterministic
// anonymization of the fieldnames to prevent information leaks.
// (ie, server gets compromised, server logged all sql queries,
// attacker can see that the admin creates the account table
// with the credit card field every time the server boots)
}
//在handler的第一阶段, 通过analysis搜集delta以及执行计划等内容, 然后在第二阶段, 实行delta以及
//执行计划, 新的lex里面包含了改写以后的语句, 直接转化成string就可以用了.
return new DDLQueryExecutor(*new_lex, std::move(a.deltas));
}
};
//################################################################Alter table handler#########################################################################################
// mysql does not support indiscriminate add-drops
// ie,
// mysql> create table pk (x integer);
......@@ -176,6 +165,11 @@ public:
AlterTableHandler() : sub_dispatcher(buildAlterSubDispatcher()) {}
};
//################################################################drop table handler#########################################################################################
class DropTableHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const
......@@ -219,6 +213,9 @@ class DropTableHandler : public DDLHandler {
}
};
//################################################################Create db handler#########################################################################################
class CreateDBHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *const lex, const Preamble &pre)
......@@ -248,6 +245,9 @@ class CreateDBHandler : public DDLHandler {
}
};
//################################################################change db handler#########################################################################################
class ChangeDBHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *const lex, const Preamble &pre)
......@@ -258,6 +258,8 @@ class ChangeDBHandler : public DDLHandler {
}
};
//################################################################drop db handler#########################################################################################
class DropDBHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *const lex, const Preamble &pre)
......@@ -274,6 +276,8 @@ class DropDBHandler : public DDLHandler {
}
};
//################################################################lock table handler#########################################################################################
class LockTablesHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *const lex, const Preamble &pre)
......@@ -289,6 +293,8 @@ class LockTablesHandler : public DDLHandler {
}
};
//################################################################Create index handler#########################################################################################
class CreateIndexHandler : public DDLHandler {
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *const lex, const Preamble &pre)
......@@ -311,6 +317,7 @@ class CreateIndexHandler : public DDLHandler {
}
};
static std::string
empty_if_null(const char *const p)
{
......@@ -323,7 +330,6 @@ AbstractQueryExecutor *DDLHandler::
transformLex(Analysis &a, LEX *lex) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(a.deltas.size() == 0);
AssignOnce<std::string> db;
......@@ -393,7 +399,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
"deltaOutputBeforeQuery failed for DDL");
this->embedded_completion_id = embedded_completion_id;
}
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl;
std::cout<<RED_BEGIN<<"rewritten DDL: "<<this->new_query<<COLOR_END<<std::endl;
return CR_QUERY_AGAIN(this->new_query);
}
......@@ -402,7 +407,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
this->ddl_res = res;
yield {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return CR_QUERY_AGAIN(
" INSERT INTO " + MetaData::Table::remoteQueryCompletion() +
" (embedded_completion_id, completion_type) VALUES"
......@@ -421,7 +425,7 @@ nextImpl(const ResType &res, const NextParams &nparams)
TEST_ErrPkt(deltaOutputAfterQuery(nparams.ps.getEConn(), this->deltas,
this->embedded_completion_id.get()),
"deltaOuputAfterQuery failed for DDL");
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield return CR_RESULTS(this->ddl_res.get());
}
......
......@@ -9,13 +9,14 @@
#include <sql_lex.h>
class DDLQueryExecutor : public AbstractQueryExecutor {
const std::string new_query;
const std::vector<std::unique_ptr<Delta> > deltas;
AssignOnce<ResType> ddl_res;
AssignOnce<uint64_t> embedded_completion_id;
public:
const std::string new_query;
DDLQueryExecutor(const LEX &new_lex,
std::vector<std::unique_ptr<Delta> > &&deltas)
: new_query(lexToQuery(new_lex)), deltas(std::move(deltas)) {}
......@@ -24,6 +25,7 @@ public:
nextImpl(const ResType &res, const NextParams &nparams);
private:
const std::vector<std::unique_ptr<Delta> > deltas;
bool stales() const {return true;}
bool usesEmbedded() const {return true;}
};
......@@ -37,11 +39,20 @@ public:
private:
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const = 0;
protected:
DDLHandler() {;}
virtual ~DDLHandler() {;}
};
class CreateTableHandler : public DDLHandler {
//must rewrite the header here or we get pure virtual function
virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const;
};
SQLDispatcher *buildDDLDispatcher();
#include <main/dispatcher.hh>
/*
This file contains functions for SQLDispatcher and
AlterDispatcher
*/
//########################SQLDispatcher#########################
bool
SQLDispatcher::canDo(LEX *const lex) const
{
......@@ -22,6 +27,9 @@ SQLDispatcher::extract(LEX *const lex) const
return lex->sql_command;
}
//#####################AlterDispatcher##########################
bool
AlterDispatcher::canDo(LEX *const lex) const
{
......
......@@ -424,7 +424,6 @@ class MultiDeleteHandler : public DMLHandler {
class SelectHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex)
const{
std::cout<<RED_BEGIN<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<COLOR_END<<std::endl<<std::endl;
//处理了选择域, 以及为having等field 设置了rewriteplain, 也就是encset, 不同的洋葱层次需要这个东西.
process_select_lex(lex->select_lex, a);
}
......@@ -1289,11 +1288,40 @@ class ShowTablesHandlers : public DMLHandler {
virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return new ShowTablesExecutor();
}
};
//add show create table handler
class ShowCreateTableHandler: public DMLHandler{
virtual void gather(Analysis &a, LEX *const lex) const
{
}
virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const
{
int elements = lex->select_lex.table_list.elements;
assert(elements==1);
TABLE_LIST *tbl = lex->select_lex.table_list.first;
std::string db(tbl->db);
std::string tbn(tbl->table_name);
TableMeta &tbm = a.getTableMeta(db,tbn);
//rewrite the table list here
LEX *const new_lex = copyWithTHD(lex);
tbl = rewrite_table_list(new_lex->select_lex.table_list.first,tbm.getAnonTableName());
new_lex->select_lex.table_list = *oneElemListWithTHD<TABLE_LIST>(tbl);
return new ShowCreateTableExecutor(*new_lex);
}
};
// FIXME: Add test to make sure handlers added successfully.
SQLDispatcher *buildDMLDispatcher()
{
......@@ -1324,6 +1352,11 @@ SQLDispatcher *buildDMLDispatcher()
h = new ShowTablesHandlers;
dispatcher->addHandler(SQLCOM_SHOW_TABLES, h);
//added
h = new ShowCreateTableHandler;
dispatcher->addHandler(SQLCOM_SHOW_CREATE,h);
return dispatcher;
}
......@@ -1332,13 +1365,9 @@ DMLQueryExecutor::
nextImpl(const ResType &res, const NextParams &nparams)
{
reenter(this->corot) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::cout<<RED_BEGIN<<"rewritten DML: "<<this->query<<COLOR_END<<std::endl;
yield return CR_QUERY_AGAIN(this->query);
TEST_ErrPkt(res.success(), "DML query failed against remote database");
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield {
try {
return CR_RESULTS(Rewriter::decryptResults(res, this->rmeta));
......@@ -1701,12 +1730,10 @@ ShowTablesExecutor::
nextImpl(const ResType &res, const NextParams &nparams)
{
reenter(this->corot) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield return CR_QUERY_AGAIN(nparams.original_query);
TEST_ErrPkt(res.success(), "show tables failed");
yield {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo();
const DatabaseMeta *const dm =
......@@ -1716,10 +1743,8 @@ nextImpl(const ResType &res, const NextParams &nparams)
std::vector<std::vector<Item *> > new_rows;
for (const auto &it : res.rows) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(1 == it.size());
for (const auto &table : dm->getChildren()) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(table.second);
if (table.second->getAnonTableName()
== ItemToString(*it.front())) {
......@@ -1731,10 +1756,54 @@ nextImpl(const ResType &res, const NextParams &nparams)
}
}
}
return CR_RESULTS(ResType(res, new_rows));
}
}
assert(false);
}
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowCreateTableExecutor::
nextImpl(const ResType &res, const NextParams &nparams){
std::cout<<"showCreateTableExecutor"<<std::endl;
//return CR_QUERY_AGAIN(nparams.original_query);
reenter(this->corot) {
yield return CR_QUERY_AGAIN(this->query);
TEST_ErrPkt(res.success(), "show create table tables failed");
yield {
//how to find schemaInfo?? we can get it directly
const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo();
const DatabaseMeta *const dm =
schema->getChild(IdentityMetaKey(nparams.default_db));
TEST_ErrPkt(dm, "failed to find the database '"
+ nparams.default_db + "'");
std::vector<std::vector<Item *> > new_rows;
//adapted from show tables;
/*for (const auto &it : res.rows) {
assert(1 == it.size());
for (const auto &table : dm->getChildren()) {
assert(table.second);
if (table.second->getAnonTableName()
== ItemToString(*it.front())) {
const IdentityMetaKey &plain_table_name
= dm->getKey(*table.second.get());
new_rows.push_back(std::vector<Item *>
{make_item_string(plain_table_name.getValue())});
}
}
}*/
return CR_RESULTS(ResType(res, new_rows));
}
}
//avoid reach the end
assert(false);
}
......@@ -96,15 +96,30 @@ private:
class ShowTablesExecutor : public AbstractQueryExecutor {
const std::vector<std::unique_ptr<Delta> > deltas;
std::string query;
public:
ShowTablesExecutor() {}
ShowTablesExecutor(){}
~ShowTablesExecutor() {}
std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams);
};
//added
class ShowCreateTableExecutor: public AbstractQueryExecutor{
std::string query;
public:
ShowCreateTableExecutor(const LEX &lex):query(lexToQuery(lex)){}
~ShowCreateTableExecutor(){}
std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams);
};
// Abstract base class for query handler.
class DMLHandler : public SQLHandler {
public:
......
......@@ -29,7 +29,6 @@
static Item *
encrypt_item(const Item &i, const OLK &olk, Analysis &a)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(!RiboldMYSQL::is_null(i));
FieldMeta * const fm = olk.key;
......@@ -55,7 +54,6 @@ static class ANON : public CItemSubtypeIT<Item_string,
virtual RewritePlan *
do_gather_type(const Item_string &i, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << " String item do_gather " << i << std::endl;
const std::string why = "is a string constant";
reason rsn(FULL_EncSet_Str, why, i);
......@@ -63,7 +61,6 @@ static class ANON : public CItemSubtypeIT<Item_string,
}
virtual Item * do_optimize_type(Item_string *i, Analysis & a) const {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return i;
}
......@@ -71,7 +68,6 @@ static class ANON : public CItemSubtypeIT<Item_string,
do_rewrite_type(const Item_string &i, const OLK &constr,
const RewritePlan &rp, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "do_rewrite_type String item " << i << std::endl;
return encrypt_item(i, constr, a);
}
......@@ -80,7 +76,6 @@ static class ANON : public CItemSubtypeIT<Item_string,
do_rewrite_insert_type(const Item_string &i, const FieldMeta &fm,
Analysis &a, std::vector<Item *> *l) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
typical_rewrite_insert_type(i, fm, a, l);
}
} ANON;
......@@ -90,7 +85,6 @@ static class ANON : public CItemSubtypeIT<Item_float,
virtual RewritePlan *
do_gather_type(const Item_float &i, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << " Float item do_gather " << i << std::endl;
const std::string why = "is a float constant";
reason rsn(PLAIN_EncSet, why, i);
......@@ -101,7 +95,6 @@ static class ANON : public CItemSubtypeIT<Item_float,
do_rewrite_type(const Item_float &i, const OLK &constr,
const RewritePlan &rp, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "do_rewrite_type Float item " << i << std::endl;
return encrypt_item(i, constr, a);
}
......@@ -110,7 +103,6 @@ static class ANON : public CItemSubtypeIT<Item_float,
do_rewrite_insert_type(const Item_float &i, const FieldMeta &fm,
Analysis &a, std::vector<Item *> *l) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
typical_rewrite_insert_type(i, fm, a, l);
}
} ANON;
......@@ -120,7 +112,6 @@ static class ANON : public CItemSubtypeIT<Item_int, Item::Type::INT_ITEM> {
virtual RewritePlan *
do_gather_type(const Item_int &i, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "CItemSubtypeIT (L966) num do_gather " << i
<< std::endl;
const std::string why = "is an int constant";
......@@ -130,7 +121,6 @@ static class ANON : public CItemSubtypeIT<Item_int, Item::Type::INT_ITEM> {
virtual Item * do_optimize_type(Item_int *i, Analysis & a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return i;
}
......@@ -138,7 +128,6 @@ static class ANON : public CItemSubtypeIT<Item_int, Item::Type::INT_ITEM> {
do_rewrite_type(const Item_int &i, const OLK &constr,
const RewritePlan &rp, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "do_rewrite_type " << i << std::endl;
return encrypt_item(i, constr, a);
......@@ -148,7 +137,6 @@ static class ANON : public CItemSubtypeIT<Item_int, Item::Type::INT_ITEM> {
do_rewrite_insert_type(const Item_int &i, const FieldMeta &fm,
Analysis &a, std::vector<Item *> *l) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
typical_rewrite_insert_type(i, fm, a, l);
}
} ANON;
......@@ -158,7 +146,6 @@ static class ANON : public CItemSubtypeIT<Item_decimal,
virtual RewritePlan *
do_gather_type(const Item_decimal &i, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "CItemSubtypeIT decimal do_gather " << i
<< std::endl;
......@@ -169,7 +156,6 @@ static class ANON : public CItemSubtypeIT<Item_decimal,
virtual Item * do_optimize_type(Item_decimal *i, Analysis & a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return i;
}
......@@ -177,7 +163,6 @@ static class ANON : public CItemSubtypeIT<Item_decimal,
do_rewrite_type(const Item_decimal &i, const OLK &constr,
const RewritePlan &rp, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "do_rewrite_type " << i << std::endl;
return encrypt_item(i, constr, a);
......@@ -187,7 +172,6 @@ static class ANON : public CItemSubtypeIT<Item_decimal,
do_rewrite_insert_type(const Item_decimal &i, const FieldMeta &fm,
Analysis &a, std::vector<Item *> *l) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
typical_rewrite_insert_type(i, fm, a, l);
}
} ANON;
......@@ -191,8 +191,6 @@ public:
RewritePlan(const EncSet &es, reason r) : r(r), es_out(es) {};
virtual ~RewritePlan() {}
reason getReason() const {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<std::endl;
std::cout<<"reson why: "<<r.why<<"reason item: "<<r.string_item<<std::endl;
return r;
}
......
......@@ -66,7 +66,6 @@ class ANON : public CItemSubtypeIT<Item_field, Item::Type::FIELD_ITEM> {
virtual RewritePlan *
do_gather_type(const Item_field &i, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<"AAAAAAAAAAAA"<<std::endl;
const std::string fieldname = i.field_name;
const std::string table =
i.table_name ? i.table_name :
......
......@@ -298,6 +298,7 @@ class CItemCompare : public CItemSubtypeFT<Item_func, FT> {
return ORD_EncSet; /* lambda */
}
};
const EncSet my_es = getEncSet();
TEST_BadItemArgumentCount(i.type(), 2, i.argument_count());
......
......@@ -58,7 +58,6 @@ std::string global_crash_point = "";
void
crashTest(const std::string &current_point) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
if (current_point == global_crash_point) {
throw CrashTestException();
}
......@@ -67,7 +66,6 @@ crashTest(const std::string &current_point) {
static inline std::string
extract_fieldname(Item_field *const i)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::stringstream fieldtemp;
fieldtemp << *i;
return fieldtemp.str();
......@@ -76,7 +74,6 @@ extract_fieldname(Item_field *const i)
static bool
sanityCheck(FieldMeta &fm)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (const auto &it : fm.getChildren()) {
OnionMeta *const om = it.second.get();
const onion o = it.first.getValue();
......@@ -93,7 +90,6 @@ sanityCheck(FieldMeta &fm)
static bool
sanityCheck(TableMeta &tm)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (const auto &it : tm.getChildren()) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const auto &fm = it.second;
......@@ -105,9 +101,7 @@ sanityCheck(TableMeta &tm)
static bool
sanityCheck(DatabaseMeta &dm)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (const auto &it : dm.getChildren()) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const auto &tm = it.second;
assert(sanityCheck(*tm.get()));
}
......@@ -117,9 +111,7 @@ sanityCheck(DatabaseMeta &dm)
static bool
sanityCheck(SchemaInfo &schema)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (const auto &it : schema.getChildren()) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const auto &dm = it.second;
assert(sanityCheck(*dm.get()));
}
......@@ -158,7 +150,6 @@ tablesSanityCheck(SchemaInfo &schema,
const std::unique_ptr<Connect> &e_conn,
const std::unique_ptr<Connect> &conn)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (const auto &dm_it : schema.getChildren()) {
const auto &db_name = dm_it.first.getValue();
std::cout<<"db_name: "<<db_name<<std::endl;
......@@ -515,7 +506,7 @@ deltaSanityCheck(const std::unique_ptr<Connect> &conn,
" SELECT id, type FROM " + embedded_completion +
" WHERE complete = FALSE AND aborted != TRUE;";
std::cout<<"query in deltaSanityCheck to find unfinished deltas: "<<unfinished_deltas<<__LINE__<<":"<<__FILE__<<std::endl;
//std::cout<<"query in deltaSanityCheck to find unfinished deltas: "<<unfinished_deltas<<__LINE__<<":"<<__FILE__<<std::endl;
RETURN_FALSE_IF_FALSE(e_conn->execute(unfinished_deltas, &dbres));
......@@ -561,7 +552,6 @@ deltaSanityCheck(const std::unique_ptr<Connect> &conn,
static bool
metaSanityCheck(const std::unique_ptr<Connect> &e_conn)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// same number of elements
{
std::unique_ptr<DBResult> regular_dbres;
......@@ -626,7 +616,6 @@ std::unique_ptr<SchemaInfo>
loadSchemaInfo(const std::unique_ptr<Connect> &conn,
const std::unique_ptr<Connect> &e_conn)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// Must be done before loading the children.
assert(deltaSanityCheck(conn, e_conn));
......@@ -665,7 +654,6 @@ translatorHelper(std::vector<std::string> texts,
static bool
buildTypeTextTranslator()
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// Onions.
const std::vector<std::string> onion_strings
{
......@@ -681,12 +669,12 @@ buildTypeTextTranslator()
// SecLevels.
const std::vector<std::string> seclevel_strings
{
"RND", "DET", "DETJOIN", "OPE", "HOM", "SEARCH", "PLAINVAL",
"RND", "DET", "DETJOIN","OPEFOREIGN" ,"OPE", "HOM", "SEARCH", "PLAINVAL",
"INVALID"
};
const std::vector<SECLEVEL> seclevels
{
SECLEVEL::RND, SECLEVEL::DET, SECLEVEL::DETJOIN, SECLEVEL::OPE,
SECLEVEL::RND, SECLEVEL::DET, SECLEVEL::DETJOIN, SECLEVEL::OPEFOREIGN,SECLEVEL::OPE,
SECLEVEL::HOM, SECLEVEL::SEARCH, SECLEVEL::PLAINVAL,
SECLEVEL::INVALID
};
......@@ -860,7 +848,6 @@ removeOnionLayer(const Analysis &a, const TableMeta &tm,
SECLEVEL *const new_level,
std::vector<std::unique_ptr<Delta> > *const deltas)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// Remove the EncLayer.
EncLayer const &back_el = om_adjustor->popBackEncLayer();
......@@ -908,7 +895,7 @@ removeOnionLayer(const Analysis &a, const TableMeta &tm,
* changed schema to persistent storage.
*
*/
static std::pair<std::vector<std::unique_ptr<Delta> >,
std::pair<std::vector<std::unique_ptr<Delta> >,
std::list<std::string>>
adjustOnion(const Analysis &a, onion o, const TableMeta &tm,
const FieldMeta &fm, SECLEVEL tolevel)
......@@ -949,7 +936,6 @@ FieldQualifies(const FieldMeta *const restriction,
template <class T>
static Item *
do_optimize_const_item(T *i, Analysis &a) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return i;
}
......@@ -959,7 +945,6 @@ static Item *
decrypt_item_layers(const Item &i, const FieldMeta *const fm, onion o,
uint64_t IV)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(!RiboldMYSQL::is_null(i));
const Item *dec = &i;
......@@ -988,7 +973,7 @@ static void optimize_select_lex(st_select_lex *select_lex, Analysis & a);
static Item *getLeftExpr(const Item_in_subselect &i)
{
Item *const left_expr =
Item *const left_expr =
i.*rob<Item_in_subselect, Item*,
&Item_in_subselect::left_expr>::ptr();
assert(left_expr);
......@@ -1006,7 +991,6 @@ static class ANON : public CItemSubtypeIT<Item_subselect,
virtual RewritePlan *
do_gather_type(const Item_subselect &i, Analysis &a) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string why = "subselect";
// create an Analysis object for subquery gathering/rewriting
......@@ -1076,7 +1060,6 @@ static class ANON : public CItemSubtypeIT<Item_subselect,
const RewritePlan &rp, Analysis &a)
const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const RewritePlanWithAnalysis &rp_w_analysis =
static_cast<const RewritePlanWithAnalysis &>(rp);
const st_select_lex *const select_lex =
......@@ -1194,38 +1177,6 @@ static class ANON : public CItemSubtypeIT<Item_cache, Item::Type::CACHE_ITEM> {
UNIMPLEMENTED;
return NULL;
/*
TEST_TextMessageError(false ==
i->field()->orig_table->alias_name_used,
"Can not mix CACHE_ITEM and table alias.");
const std::string table_name =
std::string(i->field()->orig_table->alias);
const std::string field_name =
std::string(i->field()->field_name);
OnionMeta *const om =
a.getOnionMeta(table_name, field_name, oPLAIN);
if (a.getOnionLevel(om) != SECLEVEL::PLAINVAL) {
const FieldMeta *const fm =
a.getFieldMeta(table_name, field_name);
throw OnionAdjustExcept(oPLAIN, fm, SECLEVEL::PLAINVAL,
table_name);
}
const EncSet out_es = PLAIN_EncSet;
tr = reason(out_es, "is cache item", i);
return new RewritePlan(out_es, tr);
*/
/*
Item *example = i->*rob<Item_cache, Item*, &Item_cache::example>::ptr();
if (example)
return gather(example, tr, a);
return tr.encset;
UNIMPLEMENTED;
return NULL;
*/
}
virtual Item * do_optimize_type(Item_cache *i, Analysis & a) const
......@@ -1250,7 +1201,6 @@ static class ANON : public CItemSubtypeIT<Item_cache, Item::Type::CACHE_ITEM> {
static void
optimize_select_lex(st_select_lex *select_lex, Analysis & a)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
auto item_it = List_iterator<Item>(select_lex->item_list);
for (;;) {
if (!item_it++)
......@@ -1278,7 +1228,6 @@ optimize_select_lex(st_select_lex *select_lex, Analysis & a)
static void
optimize_table_list(List<TABLE_LIST> *tll, Analysis &a)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
List_iterator<TABLE_LIST> join_it(*tll);
for (;;) {
TABLE_LIST *t = join_it++;
......@@ -1331,6 +1280,49 @@ const std::unique_ptr<SQLDispatcher> Rewriter::dml_dispatcher =
const std::unique_ptr<SQLDispatcher> Rewriter::ddl_dispatcher =
std::unique_ptr<SQLDispatcher>(buildDDLDispatcher());
static std::string serilize_OnionAdjustExcept(OnionAdjustExcept &e){
//onion and level
std::string res;
if(e.o==oDET){
res+="oDET";
}else if(e.o==oOPE){
res+="oOPE";
}else if(e.o==oAGG){
res+="oAGG";
}else if(e.o==oSWP){
res+="oSWP";
}else if(e.o==oPLAIN){
res+="oPLAIN";
}else{
res+="NULLONION";
}
res+="::::";
if(e.tolevel==SECLEVEL::INVALID){
res+="INVALID";
}else if(e.tolevel==SECLEVEL::PLAINVAL){
res+="PLAINVAL";
}else if(e.tolevel==SECLEVEL::OPEFOREIGN){
res+="OPEFOREIGN";
}else if(e.tolevel==SECLEVEL::OPE){
res+="OPE";
}else if(e.tolevel==SECLEVEL::DETJOIN){
res+="DETJOIN";
}else if(e.tolevel==SECLEVEL::DET){
res+="DET";
}else if(e.tolevel==SECLEVEL::SEARCH){
res+="SEARCH";
}else if(e.tolevel==SECLEVEL::HOM){
res+="HOM";
}else if(e.tolevel==SECLEVEL::RND){
res+="RND";
}else{
res+="nulllevel";
}
return res;
}
// NOTE : This will probably choke on multidatabase queries.
AbstractQueryExecutor *
Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
......@@ -1347,9 +1339,8 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
// optimization: do not process queries that we will not rewrite
if (noRewrite(*lex)) {
std::cout<<"we return SimpleExecutor here"<<__FILE__<<":"<<__LINE__<<std::endl;
return new SimpleExecutor();
} else if (dml_dispatcher->canDo(lex)) {
} else if (dml_dispatcher->canDo(lex)) {
// HACK: We don't want to process INFORMATION_SCHEMA queries
if (SQLCOM_SELECT == lex->sql_command &&
lex->select_lex.table_list.first) {
......@@ -1367,6 +1358,7 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
std::cout << GREEN_BEGIN << "Adjusting onion!" << COLOR_END
<< std::endl;
//We use deltas to remove layers in the metadata, and queyrs to decrypt data.
std::pair<std::vector<std::unique_ptr<Delta> >,
std::list<std::string> >
out_data = adjustOnion(a, e.o, e.tm, e.fm, e.tolevel);
......@@ -1380,7 +1372,24 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
return executor.get();
} else if (ddl_dispatcher->canDo(lex)) {
const SQLHandler &handler = ddl_dispatcher->dispatch(lex);
AbstractQueryExecutor *const executor = handler.transformLex(a, lex);
AbstractQueryExecutor * executor ;
try{
executor = handler.transformLex(a, lex);
}catch(OnionAdjustExcept e){
// if an error occur in the first line of code, gdb will go to return NULL, which is not what exactly happened.
//We use deltas to remove layers in the metadata, and queyrs to decrypt data.
std::pair<std::vector<std::unique_ptr<Delta> >,
std::list<std::string> >
out_data = adjustOnion(a, e.o, e.tm, e.fm, e.tolevel);
std::string resadjust = serilize_OnionAdjustExcept(e);
std::cout<<"###################################################**************************************"<<resadjust<<std::endl;
std::vector<std::unique_ptr<Delta> > &deltas = out_data.first;
const std::list<std::string> &adjust_queries = out_data.second;
return new OnionAdjustmentExecutor(std::move(deltas),
adjust_queries);
}
return executor;
}
......@@ -1391,7 +1400,6 @@ QueryRewrite
Rewriter::rewrite(const std::string &q, const SchemaInfo &schema,
const std::string &default_db, const ProxyState &ps)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
LOG(cdb_v) << "q " << q;
assert(0 == mysql_thread_init());
......@@ -1433,7 +1441,6 @@ std::string ReturnMeta::stringify() {
ResType
Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
//这个success是构造的时候写入的.
assert(dbres.success());
......@@ -1571,6 +1578,8 @@ OnionMetaAdjustor::pullCopyLayers(OnionMeta const &om)
return v;
}
//Write delta into the local meta database to remove layers, issuses queries to adjust layers, and then reissus the original query.
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
OnionAdjustmentExecutor::
nextImpl(const ResType &res, const NextParams &nparams)
......
......@@ -370,3 +370,14 @@ private:
bool stales() const {return true;}
bool usesEmbedded() const {return true;}
};
std::pair<std::vector<std::unique_ptr<Delta> >,
std::list<std::string>>
adjustOnion(const Analysis &a, onion o, const TableMeta &tm,
const FieldMeta &fm, SECLEVEL tolevel);
......@@ -33,8 +33,7 @@ rewrite(const Item &i, const EncSet &req_enc, Analysis &a) {
}
TABLE_LIST *
rewrite_table_list(const TABLE_LIST * const t, const Analysis &a)
{
rewrite_table_list(const TABLE_LIST * const t, const Analysis &a) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// Table name can only be empty when grouping a nested join.
assert(t->table_name || t->nested_join);
......@@ -153,14 +152,12 @@ gather(const Item &i, Analysis &a)
void
gatherAndAddAnalysisRewritePlan(const Item &i, Analysis &a)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
a.rewritePlans[&i] = std::unique_ptr<RewritePlan>(gather(i, a));
}
std::vector<std::tuple<std::vector<std::string>, Key::Keytype> >
collectKeyData(const LEX &lex)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::vector<std::tuple<std::vector<std::string>, Key::Keytype> > output;
auto key_it =
......@@ -276,14 +273,18 @@ getOriginalKeyName(const Key &key)
return "PRIMARY";
}
const std::string out_name = convert_lex_str(key.name);
std::string out_name = convert_lex_str(key.name);
TEST_TextMessageError(out_name.size() > 0,
"Non-Primary keys can not have blank name!");
//TEST_TextMessageError(out_name.size() > 0,
// "Non-Primary keys can not have blank name!");
if(out_name.size()==0){
out_name="nonekey";
}
return out_name;
}
/*
static std::vector<Key *>
rewrite_key(const TableMeta &tm, const Key &key, const Analysis &a)
{
......@@ -295,8 +296,9 @@ rewrite_key(const TableMeta &tm, const Key &key, const Analysis &a)
const std::vector<onion> key_onions = getOnionIndexTypes();
for (auto onion_it : key_onions) {
const onion o = onion_it;
THD* cthd = current_thd;
//原始key的拷贝
Key *const new_key = key.clone(current_thd->mem_root);
Key *const new_key = key.clone(cthd->mem_root);
//通过key的原始名字+onion+tm哈希获得新的key名字,用的是std::hash<string>算法.
// Set anonymous name.
const std::string new_name =
......@@ -348,12 +350,92 @@ rewrite_key(const TableMeta &tm, const Key &key, const Analysis &a)
return output_keys;
}
*/
/*
only rewrite normal keys here, do not process foreign keys.
*/
static std::vector<Key *>
rewrite_key1(const TableMeta &tm, const Key &key, const Analysis &a){
//leave foreign key unchanged
std::vector<Key *> output_keys;
if(key.type==Key::FOREIGN_KEY){
THD* cthd = current_thd;
Key *const new_key = key.clone(cthd->mem_root);
output_keys.push_back(new_key);
return output_keys;
}
//从左到右分别是三种类型: oOPE, oDET, oPLAIN, 对于每个语句的index都是这样
//比如自己要alter table add 的index, 其对应index的名字, 以及相关的column信息
//比如create的时候, 产生的index, 其对应的名字以及相关的columns, 这样包含在key里面了
const std::vector<onion> key_onions = getOnionIndexTypes();
for (auto onion_it : key_onions) {
const onion o = onion_it;
THD* cthd = current_thd;
//原始key的拷贝
Key *const new_key = key.clone(cthd->mem_root);
//通过key的原始名字+onion+tm哈希获得新的key名字,用的是std::hash<string>算法.
// Set anonymous name.
const std::string new_name =
a.getAnonIndexName(tm, getOriginalKeyName(key), o);
//设置key的新名字, 以及新的key对应的column清空??
new_key->name = string_to_lex_str(new_name);
new_key->columns.empty();
//遍历原始的key的columns, 改写, 变成新key的colukns
// Set anonymous columns.
auto col_it =
RiboldMYSQL::constList_iterator<Key_part_spec>(key.columns);
for (;;) {
const Key_part_spec *const key_part = col_it++;
if (NULL == key_part) {
output_keys.push_back(new_key);
break;
}
//复制一个column信息
Key_part_spec *const new_key_part = copyWithTHD(key_part);
//原始的key_part, 也就是一个column, 里面取一个field_name出来
const std::string field_name =
convert_lex_str(new_key_part->field_name);
//通过column查tablemeta, 然后差当前的onion在不在那个tablemeta里面
// > the onion may not exist; ie oPLAIN with SENSITIVE and not
// an AUTO INCREMENT column
const FieldMeta &fm = a.getFieldMeta(tm, field_name);
const OnionMeta *const om = fm.getOnionMeta(o);
if (NULL == om) {
break;
}
//如果存在, 那么新的column的名字就是洋葱的名字, 然后new_key的column就确定了
//可以看到, 对于索引里面的每个field, 都选择一个洋葱, 如果没有合适的, 则不选择.
new_key_part->field_name =
string_to_lex_str(om->getAnonOnionName());
new_key->columns.push_back(new_key_part);
}
}
//上面, 对于一个key来说, 可以查三个洋葱
//对于每个洋葱,都可能构造一个key, 这是根据这个key对应的columns里面有没有洋葱, 有则选进来. 所以, 列扩展了以后, 索引也扩展了.
//主键特殊处理, 之根据一个洋葱构造.
// Only create one PRIMARY KEY.
if (Key::PRIMARY == key.type) {
if (output_keys.size() > 0) {
return std::vector<Key *>({output_keys.front()});
}
}
return output_keys;
}
// 'seed_lex' and 'out_lex' can be the same object.
void
highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
LEX *const out_lex, const Analysis &a)
{
LEX *const out_lex, const Analysis &a){
assert(out_lex);
// Add each new index.
......@@ -365,7 +447,7 @@ highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
// -----------------------------
// Rewrite INDEX
// -----------------------------
auto new_keys = rewrite_key(tm, *key, a);
auto new_keys = rewrite_key1(tm, *key, a);
out_list.concat(vectorToListWithTHD(new_keys));
return out_list;
......@@ -374,6 +456,89 @@ highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
return;
}
void
highLevelRewriteForeignKey(const TableMeta &tm, const LEX &seed_lex,
LEX *const out_lex, const Analysis &a,std::string tbname){
std::string dbname = a.getDatabaseName();
auto it =
List_iterator<Key>(out_lex->alter_info.key_list);
std::vector<Key *> output_keys;
while(auto cur = it++){
if(cur->type== Key::FOREIGN_KEY){
THD* cthd = current_thd;
//process current names
Key* const new_key = cur->clone(cthd->mem_root);
std::string new_name = "newfkname";
new_key->name = string_to_lex_str(new_name);
//process current columns
auto col_it_cur = List_iterator<Key_part_spec>((cur->columns));
new_key->columns.empty();
while(1){
const Key_part_spec *const key_part = col_it_cur++;
if(NULL == key_part){
break;
}
Key_part_spec *const new_key_part = copyWithTHD(key_part);
std::string field_name =
convert_lex_str(new_key_part->field_name);
//get current field name, and then replace it with one onionname here
//currently we choose det onion, without caring about the layers
//OnionMeta *om = a.getOnionMeta2(dbname,tbname,field_name,oDET);
OnionMeta *om = tm.getChild(IdentityMetaKey(field_name))->getOnionMeta(oOPE);
assert(om!=NULL);
field_name=om->getAnonOnionName();
new_key_part->field_name = string_to_lex_str(field_name);
new_key->columns.push_back(new_key_part);
}
//process ref tables
Table_ident* ref_table = ((Foreign_key*)cur)->ref_table;
std::string ref_table_name = std::string(ref_table->table.str,ref_table->table.length);
TableMeta &rtm = a.getTableMeta(a.getDatabaseName(),ref_table_name);
std::string ref_table_annoname = rtm.getAnonTableName();
ref_table->table = string_to_lex_str(ref_table_annoname);
//process ref columns
auto col_it =
List_iterator<Key_part_spec>(((Foreign_key*)cur)->ref_columns);
((Foreign_key*)new_key)->ref_columns.empty();
while(1){
const Key_part_spec *const key_part = col_it++;
if(NULL == key_part){
break;
}
Key_part_spec *const new_key_part = copyWithTHD(key_part);
std::string field_name =
convert_lex_str(new_key_part->field_name);
//update field name here
OnionMeta * om = a.getOnionMeta2(dbname,ref_table_name,field_name,oOPE);
assert(om!=NULL);
field_name=om->getAnonOnionName();
new_key_part->field_name = string_to_lex_str(field_name);
((Foreign_key*)new_key)->ref_columns.push_back(new_key_part);
}
output_keys.push_back(new_key);
}else{
THD* cthd = current_thd;
Key* const new_key = cur->clone(cthd->mem_root);
output_keys.push_back(new_key);
}
}
out_lex->alter_info.key_list = *vectorToListWithTHD(output_keys);
}
std::string
bool_to_string(bool b)
{
......@@ -406,7 +571,7 @@ isUnique(const std::string &name,
const auto &found =
std::find(std::get<0>(it).begin(), std::get<0>(it).end(), name);
if (found != std::get<0>(it).end()
&& (std::get<1>(it) == Key::PRIMARY || std::get<1>(it) == Key::UNIQUE)) {
&& (std::get<1>(it) == Key::PRIMARY || std::get<1>(it) == Key::UNIQUE ||std::get<1>(it)==Key::FOREIGN_KEY)) {
unique = true;
break;
}
......@@ -427,19 +592,16 @@ createAndRewriteField(Analysis &a, Create_field * const cf,
cf->flags = cf->flags | UNSIGNED_FLAG;
const std::string &name = std::string(cf->field_name);
std::cout<<RED_BEGIN<<name<<":"<<cf->sql_type<<COLOR_END<<std::endl;
std::unique_ptr<FieldMeta>
fm(new FieldMeta(*cf, a.getMasterKey().get(),
a.getDefaultSecurityRating(), tm->leaseCount(),
isUnique(name, key_data)));
// -----------------------------
// Rewrite FIELD
// -----------------------------
//for each onion, we have new fields and salts, salts have long long type
const auto new_fields = rewrite_create_field(fm.get(), cf, a);
rewritten_cfield_list.concat(vectorToListWithTHD(new_fields));
// -----------------------------
// Update FIELD
// -----------------------------
......@@ -463,7 +625,6 @@ createAndRewriteField(Analysis &a, Create_field * const cf,
Item *
encrypt_item_layers(const Item &i, onion o, const OnionMeta &om,
const Analysis &a, uint64_t IV) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(!RiboldMYSQL::is_null(i));
//这里是onionMeta中的vector, enclayers.也就是洋葱不同层次的加解密通过Onionmeta以及
//encLary中的加解密算法来完成.
......@@ -480,7 +641,6 @@ std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std
assert(new_enc);
enc = new_enc;
}
// @i is const, do we don't want the caller to modify it accidentally.
assert(new_enc && new_enc != &i);
return new_enc;
......
......@@ -53,6 +53,12 @@ void
highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
LEX *const out_lex, const Analysis &a);
//added
void
highLevelRewriteForeignKey(const TableMeta &tm, const LEX &seed_lex,
LEX *const out_lex, const Analysis &a,std::string tbname);
std::string
bool_to_string(bool b);
......
......@@ -28,8 +28,6 @@ DBMeta::doFetchChildren(const std::unique_ptr<Connect> &e_conn,
std::unique_ptr<DBResult> db_res;
//这个id来自于dbobject.
const std::string parent_id = std::to_string(this->getDatabaseID());
std::cout<<"parent id: "<<parent_id<<std::endl;
const std::string serials_query =
" SELECT " + table_name + ".serial_object,"
" " + table_name + ".serial_key,"
......@@ -37,7 +35,8 @@ DBMeta::doFetchChildren(const std::unique_ptr<Connect> &e_conn,
" FROM " + table_name +
" WHERE " + table_name + ".parent_id"
" = " + parent_id + ";";
std::cout<<serials_query<<"serial query:"<<std::endl;
//all the metadata are fetched here.
//std::cout<<serials_query<<"serial query:"<<std::endl;
TEST_TextMessageError(e_conn->execute(serials_query, &db_res),
"doFetchChildren query failed");
MYSQL_ROW row;
......@@ -92,7 +91,7 @@ std::unique_ptr<OnionMeta>
OnionMeta::deserialize(unsigned int id, const std::string &serial)
{
assert(id != 0);
std::cout<<"string before unserialize: "<<serial<<std::endl;
//std::cout<<"string before unserialize: "<<serial<<std::endl;
const auto vec = unserialize_string(serial);
//OnionMeta序列化的结果有三个.
assert(3 == vec.size());
......@@ -270,6 +269,10 @@ determineSecLevelData(onion o, std::vector<SECLEVEL> levels, bool unique)
|| SECLEVEL::RND == levels.back());
} else if (oOPE == o) {
assert(SECLEVEL::RND == levels.back());
levels.pop_back();
assert(SECLEVEL::OPE == levels.back());
levels.pop_back();
assert(SECLEVEL::OPEFOREIGN==levels.back());
} else if (oAGG == o) {
assert(SECLEVEL::HOM == levels.back());
} else {
......@@ -286,10 +289,12 @@ init_onions_layout(const AES_KEY *const m_key, FieldMeta *const fm,
const onionlayout onion_layout = fm->getOnionLayout();
if (fm->getHasSalt() != (static_cast<bool>(m_key)
&& PLAIN_ONION_LAYOUT != onion_layout)) {
std::cout<<"unable to get salt?"<<std::endl;
return false;
}
if (0 != fm->getChildren().size()) {
std::cout<<"already has children"<<std::endl;
return false;
}
......@@ -331,6 +336,7 @@ FieldMeta::FieldMeta(const Create_field &field,
sec_rating(sec_rating), uniq_count(uniq_count), counter(0),
has_default(determineHasDefault(field)),
default_value(determineDefaultValue(has_default, field)) {
TEST_TextMessageError(init_onions_layout(m_key, this, field, unique),
"Failed to build onions for new FieldMeta!");
}
......@@ -409,10 +415,8 @@ onionlayout FieldMeta::determineOnionLayout(const AES_KEY *const m_key,
// assert(!m_key);
return PLAIN_ONION_LAYOUT;
}
TEST_TextMessageError(m_key,
"Should be using SECURITY_RATING::PLAIN!");
if (false == encryptionSupported(f)) {
std::cout<<"encryption not supported for this field, remain plain"<<std::endl;
//TEST_TextMessageError(SECURITY_RATING::SENSITIVE != sec_rating,
......@@ -425,7 +429,6 @@ onionlayout FieldMeta::determineOnionLayout(const AES_KEY *const m_key,
if (Field::NEXT_NUMBER == f.unireg_check) {
return PLAIN_ONION_LAYOUT;
}
if (SECURITY_RATING::SENSITIVE == sec_rating) {
if (true == isMySQLTypeNumeric(f)) {
return NUM_ONION_LAYOUT;
......
......@@ -363,7 +363,7 @@ void parseResType(const ResType &rd) {
}
*/
/*
static
void parseResType2(const ResType &rd) {
std::cout<<RED_BEGIN<<"rd.affected_rows: "<<rd.affected_rows<<COLOR_END<<std::endl;
......@@ -377,12 +377,14 @@ void parseResType2(const ResType &rd) {
}
}
}
*/
static ResType
getResTypeFromLuaTable(lua_State *const L, int fields_index,
int rows_index, int affected_rows_index,
int insert_id_index, int status_index) {
std::cout<<"decide to show luaTable to ResType:"<<std::endl;
//std::cout<<"decide to show luaTable to ResType:"<<std::endl;
const bool status = lua_toboolean(L, status_index);
if (false == status) {
return ResType(false, 0, 0);
......@@ -479,7 +481,6 @@ parseReturnMeta(const ReturnMeta & rtm){
static int
next(lua_State *const L) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// ANON_REGION(__func__, &perf_cg);
scoped_lock l(&big_lock);
assert(0 == mysql_thread_init());
......@@ -494,6 +495,7 @@ next(lua_State *const L) {
nilBuffer(L, 1);
return 5;
}
WrapperState *const c_wrapper = clients[client];
assert(EXECUTE_QUERIES);
......@@ -503,11 +505,8 @@ next(lua_State *const L) {
ps->safeCreateEmbeddedTHD();
const ResType &res = getResTypeFromLuaTable(L, 2, 3, 4, 5, 6);
parseResType2(res);
//parseResType2(res);
std::cout<<"************************************************"<<std::endl;
printRes(res);
const std::unique_ptr<QueryRewrite> &qr = c_wrapper->getQueryRewrite();
parseReturnMeta(qr->rmeta);
try {
......
assert(package.loadlib(os.getenv("EDBDIR").."/obj/libexecute.so",
"lua_cryptdb_init"))()
assert(package.loadlib("/t/cryt/obj/libexecute.so","lua_cryptdb_init"))()
local proto = assert(require("mysql.proto"))
local g_want_interim = nil
......@@ -20,7 +20,7 @@ function read_auth()
proxy.connection.server.dst.port,
os.getenv("CRYPTDB_USER") or "root",
os.getenv("CRYPTDB_PASS") or "letmein",
os.getenv("CRYPTDB_SHADOW") or os.getenv("EDBDIR").."/shadow")
os.getenv("CRYPTDB_SHADOW") or "/t/cryt/shadow")
-- EDBClient uses its own connection to the SQL server to set up UDFs
-- and to manipulate multi-principal state. (And, in the future, to
-- store its schema state for single- and multi-principal operation.)
......@@ -32,16 +32,17 @@ function disconnect_client()
end
function read_query(packet)
printred("read_query========================================================================================")
local status, err = pcall(read_query_real, packet)
if status then
return err
else
print("read_query: " .. err)
return proxy.PROXY_SEND_QUERY
end
end
function read_query_result(inj)
printred("read_query_result========================================================================================")
local status, err = pcall(read_query_result_real, inj)
if status then
return err
......@@ -52,6 +53,28 @@ function read_query_result(inj)
end
function split(pString, pPattern)
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end
--
-- Pretty printing
--
......@@ -77,6 +100,8 @@ function printred(x)
end
function printline(n)
print("#######n==")
print(n)
-- pretty printing
if (n) then
io.write("+")
......@@ -114,8 +139,14 @@ function prettyNewQuery(q)
return
end
end
print(greentext("NEW QUERY: ")..makePrintable(q))
list = split(q,',')
for i=1,#list do
io.write(string.sub(list[i],1,40))
print("")
end
--print(greentext("NEW QUERY: ")..makePrintable(q))
end
--
......@@ -130,8 +161,7 @@ end
function read_query_real(packet)
local query = string.sub(packet, 2)
print("================================================")
printred("QUERY: ".. query)
--printred("QUERY: ".. query)
if string.byte(packet) == proxy.COM_INIT_DB then
query = "USE `" .. query .. "`"
......@@ -156,6 +186,12 @@ function read_query_real(packet)
end
end
function printRowsAndFields(inj)
local resultset = inj.resultset
end
function read_query_result_real(inj)
local query = inj.query:sub(2)
prettyNewQuery(query)
......@@ -192,12 +228,9 @@ function read_query_result_real(inj)
interim_fields[i] =
{ type = resfields[i].type,
name = resfields[i].name }
io.write(string.format("%-20s|",rfi.name))
io.write(string.format("%-10s|",rfi.name))
end
print()
printline(#resfields)
local resrows = resultset.rows
if resrows then
for row in resrows do
......@@ -209,10 +242,11 @@ function read_query_result_real(inj)
print()
end
end
printline(#resfields)
--printline(#resfields)
end
print(greentext("ENCRYPTED RESULTS END"))
return next_handler("results", true, client, interim_fields, interim_rows,
resultset.affected_rows, resultset.insert_id)
end
......@@ -278,5 +312,3 @@ function next_handler(from, status, client, fields, rows, affected_rows,
assert(nil)
end
print("hehe")
......@@ -126,10 +126,9 @@ std::string ListJoin(List<T> lst, std::string delim,
auto it = List_iterator<T>(lst);
for (T *element = it++; element; element = it++) {
std::string finalized_element = finalize(*element);
accum << finalized_element;
accum << delim;
accum << finalized_element;
accum << delim;
}
std::string output, str_accum = accum.str();
if (str_accum.length() > 0) {
output = str_accum.substr(0, str_accum.length() - delim.length());
......@@ -530,10 +529,28 @@ prefix_add_index(Key key)
key_output << ListJoin<Key_part_spec>(key.columns, ",",
do_prefix_add_index())
<< ")";
return key_output.str();
}
static std::string
prefix_add_foreign(Key *key){
const std::string index_name = convert_lex_str(key->name);
std::ostringstream key_output;
key_output << " ADD constraint "<<" FOREIGN KEY "<<index_name<<" (";
key_output << ListJoin<Key_part_spec>(key->columns, ",",
do_prefix_add_index())
<< ")";
Table_ident* ref_table = ((Foreign_key*)key)->ref_table;
std::string ref_table_name = convert_lex_str(ref_table->table);
key_output <<" REFERENCES "<< ref_table_name<<" (";
key_output<<ListJoin<Key_part_spec>( ((Foreign_key*)key)->ref_columns,",",do_prefix_add_index())<<" )";
return key_output.str();
}
static std::string
enableOrDisableKeysOutput(const LEX &lex)
{
......@@ -565,6 +582,71 @@ prettyLockType(enum thr_lock_type lock_type)
}
*/
//process normal key in alter table command, do not process foreign key
static std::string process_normal_key(LEX &lex){
std::ostringstream key_output;
auto it =
List_iterator<Key>(lex.alter_info.key_list);
while(auto cur = it++){
switch(cur->type){
case Key::PRIMARY:{
key_output<<prefix_add_index(*cur)<<",";
break;
}
case Key::UNIQUE:
case Key::MULTIPLE:
case Key::FULLTEXT:
case Key::SPATIAL:{
key_output<<prefix_add_index(*cur)<<",";
break;
}
case Key::FOREIGN_KEY:{
break;
}
default:{
break;
}
}
}
std::string orig = key_output.str();
std::string res = orig.substr(0,orig.length()-1);
return res;
}
static std::string process_foreign_key(LEX &lex){
std::ostringstream key_output;
auto it =
List_iterator<Key>(lex.alter_info.key_list);
while(auto cur = it++){
switch(cur->type){
case Key::PRIMARY:{
break;
}
case Key::UNIQUE:
case Key::MULTIPLE:
case Key::FULLTEXT:
case Key::SPATIAL:{
break;
}
case Key::FOREIGN_KEY:{
key_output<<prefix_add_foreign(cur)<<",";
break;
}
default:{
break;
}
}
}
std::string orig = key_output.str();
std::string res = orig.substr(0,orig.length()-1);
return res;
}
static inline std::ostream&
operator<<(std::ostream &out, LEX &lex)
{
......@@ -886,16 +968,31 @@ operator<<(std::ostream &out, LEX &lex)
",", prefix_add_column);
prev = true;
}
if(lex.alter_info.flags & ALTER_FOREIGN_KEY){
if (true == prev) {
out << ", ";
}
std::string keys;
keys = process_foreign_key(lex);
out<<" "<<keys;
prev = true;
}
if (lex.alter_info.flags & ALTER_ADD_INDEX) {
if (true == prev) {
out << ", ";
}
out << " " << ListJoin<Key>(lex.alter_info.key_list, ",",
prefix_add_index);
//process primary and index here
//out << " " << ListJoin<Key>(lex.alter_info.key_list, ",",
// prefix_add_index);
//get a vector of key type, key name, and key columns
std::string keys;
keys = process_normal_key(lex);
out<<" "<<keys;
prev = true;
}
if (lex.alter_info.flags & ALTER_DROP_INDEX) {
if (true == prev) {
out << ", ";
......@@ -940,7 +1037,19 @@ operator<<(std::ostream &out, LEX &lex)
/* placeholders to make analysis work.. */
out << ".. type " << lex.sql_command << " query ..";
break;
//ADDED
case SQLCOM_SHOW_CREATE:{
int elements = lex.select_lex.table_list.elements;
if(elements==1){
TABLE_LIST *tbl = lex.select_lex.table_list.first;
std::string db(tbl->db);
std::string tbn(tbl->table_name);
out<< "SHOW CREATE TABLE "+db+"."+tbn;
}else{
out<<"ONLY SUPPORT ONE TABLE";
}
break;
}
default:
thrower() << "unhandled sql command " << lex.sql_command;
}
......@@ -948,3 +1057,5 @@ operator<<(std::ostream &out, LEX &lex)
return out;
}
/t/mysql-src/build/client/mysql -uroot -pletmein -h 127.0.0.1 -P3399
[mysql-proxy]
plugins = proxy
event-threads = 4
proxy-lua-script = /t/cryt/mysqlproxy/wrapper.lua
proxy-address = 127.0.0.1:3399
proxy-backen-addresses = 127.0.0.1:3306
[mysql-proxy]
plugins = proxy
event-threads = 4
proxy-lua-script = /t/cryt/tutorial-basic.lua
proxy-address = 127.0.0.1:3399
proxy-backen-addresses = 127.0.0.1:3306
mysql-proxy --defaults-file=./mysql-proxy2.cnf
rm -rf ./shadow/* ./shadowtest/*
mysql -uroot -pletmein < reset.sql
drop database if exists tf;
drop database if exists tdb;
drop database if exists tdb2;
drop database if exists tdb3;
drop database if exists remote_db;
drop database if exists cryptdb_udf;
mysql-proxy --defaults-file=/t/cryt/mysql-proxy.cnf
./obj/main/cdb_test
COLOR_END = '\027[00m'
function redtext(x)
return '\027[1;31m' .. x .. COLOR_END
end
function greentext(x)
return '\027[1;92m'.. x .. COLOR_END
end
function orangetext(x)
return '\027[01;33m'.. x .. COLOR_END
end
g=1
queryType = {}
queryType[proxy.COM_SLEEP] = "COM_SLEEP"
queryType[proxy.COM_QUIT] = "COM_QUIT"
queryType[proxy.COM_INIT_DB] = "COM_INIT_DB"
queryType[proxy.COM_QUERY] = "COM_QUERY"
queryType[proxy.COM_FIELD_LIST]= "COM_FIELD_LIST"
queryType[proxy.COM_CREATE_DB]= "COM_CREATE_DB"
queryType[proxy.COM_DROP_DB]= "COM_DROP_DB"
queryType[proxy.COM_REFRESH]= "COM_REFRESH"
queryType[proxy.COM_SHUTDOWN] = "COM_SHUTDOWN"
queryType[proxy.COM_STATISTICS] = "COM_STATISTICS"
queryType[proxy.COM_PROCESS_INFO] = "COM_PROCESS_INFO"
queryType[proxy.COM_CONNECT] = "COM_CONNECT"
queryType[proxy.COM_PROCESS_KILL] = "COM_PROCESS_KILL"
queryType[proxy.COM_DEBUG] = "COM_DEBUG"
queryType[proxy.COM_PING] = "COM_PING"
queryType[proxy.COM_TIME] = "COM_TIME"
queryType[proxy.COM_DELAYED_INSERT] = "COM_DELAYED_INSERT"
queryType[proxy.COM_CHANGE_USER] = "COM_CHANGE_USER"
queryType[proxy.COM_BINLOG_DUMP] = "COM_BINLOG_DUMP"
queryType[proxy.COM_TABLE_DUMP] = "COM_TABLE_DUMP"
queryType[proxy.COM_CONNECT_OUT] = "COM_CONNECT_OUT"
queryType[proxy.COM_REGISTER_SLAVE] = "COM_REGISTER_SLAVE"
queryType[proxy.COM_STMT_PREPARE] = "COM_STMT_PREPARE"
queryType[proxy.COM_STMT_EXECUTE] = "COM_STMT_EXECUTE"
queryType[proxy.COM_STMT_SEND_LONG_DATA] = "COM_STMT_SEND_LONG_DATA"
queryType[proxy.COM_STMT_CLOSE] = "COM_STMT_CLOSE"
queryType[proxy.COM_STMT_RESET] = "COM_STMT_RESET"
queryType[proxy.COM_SET_OPTION] = "COM_SET_OPTION"
queryType[proxy.COM_STMT_FETCH] = "COM_STMT_FETCH"
queryType[proxy.COM_DAEMON] = "COM_DAEMON"
function printCS()
server = nil
client = nil
sp = nil
if proxy.connection.client ~= nil then
client = proxy.connection.client.src.name
end
if proxy.connection.server ~= nil then
server = proxy.connection.server.dst.address
sp = proxy.connection.server.dst.port
end
if client~= nil then
print(redtext("clientName:"..client))
else
print(redtext("clientName=nil"))
end
if server ~= nil then
print(redtext(server))
else
print(redtext("server=nil"))
end
if sp ~= nil then
print(redtext(sp))
else
print(redtext("sp = nil"))
end
end
function connect_server()
print(orangetext("connect_server"))
printCS()
if g == 1 then
g = 0
else g = 1
end
print("g "..g)
print("ndx "..proxy.connection.backend_ndx.."get: "..#proxy.global.backends)
end
function read_handshake()
print(orangetext("read_handshake"))
printCS()
end
function read_auth()
print(orangetext("read_auth"))
printCS()
end
function read_auth_result()
print(orangetext("read_auth_result"))
printCS()
end
function read_query( packet )
print(orangetext("read_query"))
print(redtext("query type: "..queryType[string.byte(packet)]))
printCS()
if string.byte(packet) == proxy.COM_QUERY then
print("we got a normal query: " .. string.sub(packet, 2))
proxy.queries:append(1, packet, {resultset_is_needed = true})
return proxy.PROXY_SEND_QUERY
else
print("we got a abnormal query: " .. string.sub(packet, 2))
end
end
function print_fields(infields)
local resfields = infields
local interim_fields = {}
--store fileds in interim_fields
if (#resfields) then
io.write("|")
end
for i = 1, #resfields do
rfi = resfields[i]
interim_fields[i] ={ type = resfields[i].type,name = resfields[i].name }
io.write(string.format("%-20s|",rfi.name))
end
end
function print_rows(inrows)
local resrows = inrows
local interim_rows = {}
for row in resrows do
table.insert(interim_rows, row)
io.write("|")
-- for key,value in pairs(row) do
-- io.write(string.format("%-20s|", value))
-- end
for k,v in pairs(row) do
if v ~= nil then
io.write(string.format("%-20s|", v))
io.write("size = "..string.len(v))
else
io.write(string.format("%-20s|", "nil"))
end
end
print()
end
end
function read_query_result(inj)
print(orangetext("read_query_result"))
printCS()
print("ROWS: "..type(inj.resultset.rows))
if inj.resultset.rows ~= nil then
print_fields(inj.resultset.fields)
print("finish fields")
print_rows(inj.resultset.rows)
end
end
###stop gdb
ps aux|grep gdb|grep -v grep|awk '{print $2}'| while read line;do sudo kill -9 $line;done
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,7 +4,7 @@ UTILSRC := onions.cc cryptdb_log.cc ctr.cc util.cc version.cc
all: $(OBJDIR)/libedbutil.so $(OBJDIR)/libedbutil.a
$(OBJDIR)/libedbutil.so: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(CXX) -shared -o $@ $^ $(LDFLAGS) -lntl -lcrypto -lgmp
$(CXX) -fPIC -shared -o $@ $^ $(LDFLAGS) -lntl -lcrypto -lgmp
$(OBJDIR)/libedbutil.a: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(AR) r $@ $^
......
#include<stdio.h>
void help(){
printf("help\n");
}
......@@ -25,6 +25,7 @@ typedef enum onion {
enum class SECLEVEL {
INVALID,
PLAINVAL,
OPEFOREIGN,
OPE,
DETJOIN,
DET,
......@@ -43,14 +44,14 @@ static onionlayout PLAIN_ONION_LAYOUT = {
static onionlayout NUM_ONION_LAYOUT = {
{oDET, std::vector<SECLEVEL>({SECLEVEL::DETJOIN, SECLEVEL::DET,
SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPE, SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPEFOREIGN,SECLEVEL::OPE, SECLEVEL::RND})},
{oAGG, std::vector<SECLEVEL>({SECLEVEL::HOM})}
};
static onionlayout BEST_EFFORT_NUM_ONION_LAYOUT = {
{oDET, std::vector<SECLEVEL>({SECLEVEL::DETJOIN, SECLEVEL::DET,
SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPE, SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPEFOREIGN,SECLEVEL::OPE, SECLEVEL::RND})},
{oAGG, std::vector<SECLEVEL>({SECLEVEL::HOM})},
// Requires SECLEVEL::DET, otherwise you will have to implement
// encoding for negative numbers in SECLEVEL::RND.
......@@ -61,7 +62,7 @@ static onionlayout BEST_EFFORT_NUM_ONION_LAYOUT = {
static onionlayout STR_ONION_LAYOUT = {
{oDET, std::vector<SECLEVEL>({SECLEVEL::DETJOIN, SECLEVEL::DET,
SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPE, SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPEFOREIGN,SECLEVEL::OPE, SECLEVEL::RND})},
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::SEARCH})}
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::PLAINVAL, SECLEVEL::DET,
// SECLEVEL::RND})}
......@@ -70,7 +71,7 @@ static onionlayout STR_ONION_LAYOUT = {
static onionlayout BEST_EFFORT_STR_ONION_LAYOUT = {
{oDET, std::vector<SECLEVEL>({SECLEVEL::DETJOIN, SECLEVEL::DET,
SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPE, SECLEVEL::RND})},
{oOPE, std::vector<SECLEVEL>({SECLEVEL::OPEFOREIGN,SECLEVEL::OPE, SECLEVEL::RND})},
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::SEARCH})},
// {oSWP, std::vector<SECLEVEL>({SECLEVEL::PLAINVAL, SECLEVEL::DET,
// SECLEVEL::RND})},
......
assert(package.loadlib("/t/cryt/obj/libexecute.so","lua_cryptdb_init"))()
local handle = io.popen('pwd')
local result = handle:read("*a")
handle:close()
prefix = result:gsub("\n$", "")
libpath = prefix.."/obj/libexecute.so"
assert(package.loadlib(libpath,
"lua_cryptdb_init"))()
local proto = assert(require("mysql.proto"))
local g_want_interim = nil
......@@ -20,7 +25,7 @@ function read_auth()
proxy.connection.server.dst.port,
os.getenv("CRYPTDB_USER") or "root",
os.getenv("CRYPTDB_PASS") or "letmein",
os.getenv("CRYPTDB_SHADOW") or "/t/cryt/shadow")
os.getenv("CRYPTDB_SHADOW") or prefix.."/shadow")
-- EDBClient uses its own connection to the SQL server to set up UDFs
-- and to manipulate multi-principal state. (And, in the future, to
-- store its schema state for single- and multi-principal operation.)
......@@ -32,17 +37,16 @@ function disconnect_client()
end
function read_query(packet)
printred("read_query========================================================================================")
local status, err = pcall(read_query_real, packet)
if status then
return err
else
print("read_query: " .. err)
return proxy.PROXY_SEND_QUERY
end
end
function read_query_result(inj)
printred("read_query_result========================================================================================")
local status, err = pcall(read_query_result_real, inj)
if status then
return err
......@@ -53,28 +57,6 @@ function read_query_result(inj)
end
function split(pString, pPattern)
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end
--
-- Pretty printing
--
......@@ -100,8 +82,6 @@ function printred(x)
end
function printline(n)
print("#######n==")
print(n)
-- pretty printing
if (n) then
io.write("+")
......@@ -139,14 +119,8 @@ function prettyNewQuery(q)
return
end
end
list = split(q,',')
for i=1,#list do
io.write(string.sub(list[i],1,40))
print("")
end
--print(greentext("NEW QUERY: ")..makePrintable(q))
print(greentext("NEW QUERY: ")..makePrintable(q))
end
--
......@@ -161,7 +135,8 @@ end
function read_query_real(packet)
local query = string.sub(packet, 2)
--printred("QUERY: ".. query)
print("================================================")
printred("QUERY: ".. query)
if string.byte(packet) == proxy.COM_INIT_DB then
query = "USE `" .. query .. "`"
......@@ -186,12 +161,6 @@ function read_query_real(packet)
end
end
function printRowsAndFields(inj)
local resultset = inj.resultset
end
function read_query_result_real(inj)
local query = inj.query:sub(2)
prettyNewQuery(query)
......@@ -228,9 +197,12 @@ function read_query_result_real(inj)
interim_fields[i] =
{ type = resfields[i].type,
name = resfields[i].name }
io.write(string.format("%-10s|",rfi.name))
io.write(string.format("%-20s|",rfi.name))
end
print()
printline(#resfields)
local resrows = resultset.rows
if resrows then
for row in resrows do
......@@ -242,10 +214,9 @@ function read_query_result_real(inj)
print()
end
end
--printline(#resfields)
end
print(greentext("ENCRYPTED RESULTS END"))
printline(#resfields)
end
return next_handler("results", true, client, interim_fields, interim_rows,
resultset.affected_rows, resultset.insert_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment