summaryrefslogtreecommitdiff
path: root/innobase/pars/pars0pars.c
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2004-04-07 19:07:44 +0200
committerunknown <pem@mysql.com>2004-04-07 19:07:44 +0200
commitc635d37479fbf8aa0da03d47f264ab9907cfe72b (patch)
treee5ac1517ff3dccc42352b7bac39ecd1c093d0ae6 /innobase/pars/pars0pars.c
parent8468cde4f1e028b380c24d0bac28402678568d81 (diff)
parent0948f9769b3e3da2e064e65015b86644af4acd78 (diff)
downloadmariadb-git-c635d37479fbf8aa0da03d47f264ab9907cfe72b.tar.gz
Merge 4.1 -> 5.0.
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqltest.c: Auto merged configure.in: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/mysql_com.h: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged myisam/myisamdef.h: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/insert_select.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/null.result: Auto merged mysql-test/r/connect.result: Auto merged mysql-test/r/func_sapdb.result: Auto merged mysql-test/r/mix_innodb_myisam_binlog.result: Auto merged mysql-test/r/mysqldump.result: Auto merged mysql-test/r/rpl_change_master.result: Auto merged mysql-test/r/rpl_log.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/symlink.result: Auto merged mysql-test/r/rpl_flush_log_loop.result: Auto merged mysql-test/r/rpl_flush_tables.result: Auto merged mysql-test/r/rpl_loaddata.result: Auto merged mysql-test/r/rpl_loaddata_rule_m.result: Auto merged mysql-test/r/rpl_loaddata_rule_s.result: Auto merged mysql-test/r/rpl_max_relay_size.result: Auto merged mysql-test/r/rpl_reset_slave.result: Auto merged mysql-test/r/rpl_temporary.result: Auto merged mysql-test/r/rpl_until.result: Auto merged mysql-test/r/rpl_user_variables.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/func_sapdb.test: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/rpl_change_master.test: Auto merged mysql-test/t/rpl_log.test: Auto merged mysql-test/t/variables.test: Auto merged netware/BUILD/compile-linux-tools: Auto merged netware/BUILD/compile-netware-END: Auto merged netware/BUILD/compile-netware-all: Auto merged netware/BUILD/compile-netware-standard: Auto merged mysql-test/t/rpl_empty_master_crash.test: Auto merged mysql-test/t/rpl_error_ignored_table.test: Auto merged mysql-test/t/rpl_flush_log_loop.test: Auto merged mysql-test/t/rpl_loaddata.test: Auto merged mysql-test/t/rpl_loaddata_rule_m.test: Auto merged mysql-test/t/rpl_loaddata_rule_s.test: Auto merged mysql-test/t/rpl_max_relay_size.test: Auto merged mysql-test/t/rpl_openssl.test: Auto merged mysql-test/t/rpl_relayrotate-slave.opt: Auto merged mysql-test/t/rpl_reset_slave.test: Auto merged mysql-test/t/rpl_trunc_binlog.test: Auto merged mysql-test/t/rpl_until.test: Auto merged mysql-test/t/rpl_user_variables.test: Auto merged mysql-test/t/subselect.test: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged scripts/mysql_install_db.sh: Auto merged sql/filesort.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_create.cc: Auto merged sql/item_create.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.h: Auto merged sql/lock.cc: Auto merged sql/log_event.h: Auto merged sql/mysqld.cc: Auto merged sql/net_serv.cc: Auto merged sql/protocol.cc: Auto merged sql/protocol.h: Auto merged sql/repl_failsafe.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_derived.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_list.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_repl.h: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_test.cc: Auto merged sql/sql_update.cc: Auto merged sql-common/client.c: Auto merged tests/client_test.c: Auto merged
Diffstat (limited to 'innobase/pars/pars0pars.c')
-rw-r--r--innobase/pars/pars0pars.c258
1 files changed, 21 insertions, 237 deletions
diff --git a/innobase/pars/pars0pars.c b/innobase/pars/pars0pars.c
index 3e43b6ae262..5bbfca831f2 100644
--- a/innobase/pars/pars0pars.c
+++ b/innobase/pars/pars0pars.c
@@ -29,13 +29,14 @@ on 1/27/1998 */
#include "trx0trx.h"
#include "trx0roll.h"
#include "lock0lock.h"
-#include "odbc0odbc.h"
#include "eval0eval.h"
+#ifdef UNIV_SQL_DEBUG
/* If the following is set TRUE, the lexer will print the SQL string
as it tokenizes it */
ibool pars_print_lexed = FALSE;
+#endif /* UNIV_SQL_DEBUG */
/* Global variable used while parsing a single procedure or query : the code is
NOT re-entrant */
@@ -389,7 +390,7 @@ pars_resolve_exp_variables_and_types(
}
if (!node) {
- printf("PARSER ERROR: Unresolved identifier %s\n",
+ fprintf(stderr, "PARSER ERROR: Unresolved identifier %s\n",
sym_node->name);
}
@@ -522,25 +523,6 @@ pars_resolve_exp_list_columns(
}
/*************************************************************************
-Retrieves the stored procedure definition for a procedure name. */
-static
-void
-pars_retrieve_procedure_def(
-/*========================*/
- sym_node_t* sym_node) /* in: procedure name node */
-{
- ut_a(sym_node);
- ut_a(que_node_get_type(sym_node) == QUE_NODE_SYMBOL);
-
- sym_node->resolved = TRUE;
- sym_node->token_type = SYM_PROCEDURE_NAME;
-
- sym_node->procedure_def = dict_procedure_get((char*)sym_node->name,
- NULL);
- ut_a(sym_node->procedure_def);
-}
-
-/*************************************************************************
Retrieves the table definition for a table name id. */
static
void
@@ -1662,219 +1644,22 @@ pars_procedure_definition(
/*****************************************************************
Parses a stored procedure call, when this is not within another stored
-procedure, that is, the client issues a procedure call directly. */
+procedure, that is, the client issues a procedure call directly.
+In MySQL/InnoDB, stored InnoDB procedures are invoked via the
+parsed procedure tree, not via InnoDB SQL, so this function is not used. */
que_fork_t*
pars_stored_procedure_call(
/*=======================*/
/* out: query graph */
- sym_node_t* sym_node) /* in: stored procedure name */
+ sym_node_t* sym_node __attribute__((unused)))
+ /* in: stored procedure name */
{
- call_node_t* node;
- que_fork_t* fork;
- que_thr_t* thr;
- mem_heap_t* heap;
-
- heap = pars_sym_tab_global->heap;
-
- fork = que_fork_create(NULL, NULL, QUE_FORK_PROCEDURE_CALL, heap);
- fork->trx = NULL;
-
- thr = que_thr_create(fork, heap);
-
- node = mem_heap_alloc(heap, sizeof(call_node_t));
-
- thr->child = node;
-
- node->common.type = QUE_NODE_CALL;
- node->common.parent = thr;
-
- sym_node->token_type = SYM_PROCEDURE_NAME;
-
- pars_retrieve_procedure_def(sym_node);
-
- node->procedure_def = sym_node->procedure_def;
- node->proc_name = sym_node;
-
- node->sym_tab = pars_sym_tab_global;
-
- pars_sym_tab_global->query_graph = fork;
-
- return(fork);
-}
-
-/*****************************************************************
-Writes info about query parameter markers (denoted with '?' in ODBC) into a
-buffer. */
-
-ulint
-pars_write_query_param_info(
-/*========================*/
- /* out: number of bytes used for info in buf */
- byte* buf, /* in: buffer which must be big enough */
- que_fork_t* graph) /* in: parsed query graph */
-{
- que_thr_t* thr;
- call_node_t* call_node;
- dict_proc_t* procedure_def;
- que_t* stored_graph;
- proc_node_t* proc_node;
- sym_node_t* param;
- ulint n_params;
- ibool is_input;
-
- /* We currently support parameter markers only in stored procedure
- calls, and there ALL procedure parameters must be marked with '?':
- no literal values are allowed */
-
- thr = UT_LIST_GET_FIRST(graph->thrs);
-
- n_params = 0;
-
- if (que_node_get_type(thr->child) == QUE_NODE_CALL) {
- call_node = thr->child;
-
- procedure_def = call_node->procedure_def;
-
- stored_graph = dict_procedure_reserve_parsed_copy(
- procedure_def);
- proc_node = que_fork_get_child(stored_graph);
-
- param = proc_node->param_list;
-
- while (param) {
- if (param->param_type == PARS_INPUT) {
- is_input = TRUE;
- } else {
- is_input = FALSE;
- }
-
- mach_write_to_1(buf + 4 + n_params, is_input);
-
- n_params++;
-
- param = que_node_get_next(param);
- }
-
- dict_procedure_release_parsed_copy(stored_graph);
- }
-
- mach_write_to_4(buf, n_params);
-
- return(4 + n_params);
+ ut_error;
+ return(NULL);
}
/*****************************************************************
-Reads stored procedure input parameter values from a buffer. */
-
-void
-pars_proc_read_input_params_from_buf(
-/*=================================*/
- que_t* graph, /* in: query graph which contains a stored procedure */
- byte* buf) /* in: buffer */
-{
- que_thr_t* thr;
- proc_node_t* proc_node;
- sym_node_t* param;
- byte* ptr;
- ulint len;
- lint odbc_len;
-
- ut_ad(graph->fork_type == QUE_FORK_PROCEDURE);
-
- thr = UT_LIST_GET_FIRST(graph->thrs);
-
- proc_node = thr->child;
-
- ptr = buf;
-
- param = proc_node->param_list;
-
- while (param) {
- if (param->param_type == PARS_INPUT) {
- odbc_len = (lint)mach_read_from_4(ptr);
-
- ptr += 4;
-
- if (odbc_len == SQL_NULL_DATA) {
- len = UNIV_SQL_NULL;
- } else {
- len = (ulint)odbc_len;
- }
-
- eval_node_copy_and_alloc_val(param, ptr, len);
-
- if (len != UNIV_SQL_NULL) {
- ptr += len;
- }
- }
-
- param = que_node_get_next(param);
- }
-
- ut_ad(ptr - buf < ODBC_DATAGRAM_SIZE);
-}
-
-/*****************************************************************
-Writes stored procedure output parameter values to a buffer. */
-
-ulint
-pars_proc_write_output_params_to_buf(
-/*=================================*/
- /* out: bytes used in buf */
- byte* buf, /* in: buffer which must be big enough */
- que_t* graph) /* in: query graph which contains a stored procedure */
-{
- que_thr_t* thr;
- proc_node_t* proc_node;
- sym_node_t* param;
- dfield_t* dfield;
- byte* ptr;
- ulint len;
- lint odbc_len;
-
- ut_ad(graph->fork_type == QUE_FORK_PROCEDURE);
-
- thr = UT_LIST_GET_FIRST(graph->thrs);
-
- proc_node = thr->child;
-
- ptr = buf;
-
- param = proc_node->param_list;
-
- while (param) {
- if (param->param_type == PARS_OUTPUT) {
- dfield = que_node_get_val(param);
-
- len = dfield_get_len(dfield);
-
- if (len == UNIV_SQL_NULL) {
- odbc_len = SQL_NULL_DATA;
- } else {
- odbc_len = (lint)len;
- }
-
- mach_write_to_4(ptr, (ulint)odbc_len);
-
- ptr += 4;
-
- if (len != UNIV_SQL_NULL) {
- ut_memcpy(ptr, dfield_get_data(dfield), len);
-
- ptr += len;
- }
- }
-
- param = que_node_get_next(param);
- }
-
- ut_ad(ptr - buf < ODBC_DATAGRAM_SIZE);
-
- return((ulint)(ptr - buf));
-}
-
-/*****************************************************************
Retrieves characters to the lexical analyzer. */
void
@@ -1886,13 +1671,12 @@ pars_get_lex_chars(
in the buffer */
{
int len;
- char print_buf[16];
len = pars_sym_tab_global->string_len
- pars_sym_tab_global->next_char_pos;
if (len == 0) {
#ifdef YYDEBUG
- /* printf("SQL string ends\n"); */
+ /* fputs("SQL string ends\n", stderr); */
#endif
*result = 0;
@@ -1903,18 +1687,18 @@ pars_get_lex_chars(
len = max_size;
}
+#ifdef UNIV_SQL_DEBUG
if (pars_print_lexed) {
if (len >= 5) {
len = 5;
}
-
- ut_memcpy(print_buf, pars_sym_tab_global->sql_string +
- pars_sym_tab_global->next_char_pos, len);
- print_buf[len] = '\0';
-
- printf("%s", print_buf);
+
+ fwrite(pars_sym_tab_global->sql_string +
+ pars_sym_tab_global->next_char_pos,
+ 1, len, stderr);
}
+#endif /* UNIV_SQL_DEBUG */
ut_memcpy(buf, pars_sym_tab_global->sql_string +
pars_sym_tab_global->next_char_pos, len);
@@ -1944,7 +1728,7 @@ yyerror(
{
ut_ad(s);
- printf("PARSER ERROR: Syntax error in SQL string\n");
+ fputs("PARSER ERROR: Syntax error in SQL string\n", stderr);
ut_error;
}
@@ -1968,10 +1752,10 @@ pars_sql(
heap = mem_heap_create(256);
+#ifdef UNIV_SYNC_DEBUG
/* Currently, the parser is not reentrant: */
-
ut_ad(mutex_own(&(dict_sys->mutex)));
-
+#endif /* UNIV_SYNC_DEBUG */
pars_sym_tab_global = sym_tab_create(heap);
len = ut_strlen(str);
@@ -1996,7 +1780,7 @@ pars_sql(
graph->sym_tab = pars_sym_tab_global;
- /* printf("SQL graph size %lu\n", mem_heap_get_size(heap)); */
+ /* fprintf(stderr, "SQL graph size %lu\n", mem_heap_get_size(heap)); */
return(graph);
}