Commit 5e1e279b authored by jan's avatar jan

Add general function to evaluate a sql query. Add function to evaluate

dulints in host variables.
parent 6e6c0a42
...@@ -1246,7 +1246,7 @@ dict_create_or_check_foreign_constraint_tables(void) ...@@ -1246,7 +1246,7 @@ dict_create_or_check_foreign_constraint_tables(void)
} }
/******************************************************************** /********************************************************************
Evaluate the given SQL statement. */ Evaluate the given foreign key SQL statement. */
ulint ulint
dict_foreign_eval_sql( dict_foreign_eval_sql(
...@@ -1258,26 +1258,10 @@ dict_foreign_eval_sql( ...@@ -1258,26 +1258,10 @@ dict_foreign_eval_sql(
dict_foreign_t* foreign,/* in: foreign */ dict_foreign_t* foreign,/* in: foreign */
trx_t* trx) /* in: transaction */ trx_t* trx) /* in: transaction */
{ {
que_thr_t* thr;
que_t* graph;
ulint error; ulint error;
FILE* ef = dict_foreign_err_file; FILE* ef = dict_foreign_err_file;
graph = pars_sql(info, sql); error = que_eval_sql(info, sql, trx);
ut_a(graph);
graph->trx = trx;
trx->graph = NULL;
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
ut_a(thr = que_fork_start_command(graph));
que_run_threads(thr);
error = trx->error_state;
que_graph_free(graph);
if (error == DB_DUPLICATE_KEY) { if (error == DB_DUPLICATE_KEY) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
......
...@@ -909,7 +909,6 @@ dict_tables_have_same_db( ...@@ -909,7 +909,6 @@ dict_tables_have_same_db(
dbname '/' tablename */ dbname '/' tablename */
const char* name2); /* in: table name in the form const char* name2); /* in: table name in the form
dbname '/' tablename */ dbname '/' tablename */
/************************************************************************* /*************************************************************************
Scans from pointer onwards. Stops if is at the start of a copy of Scans from pointer onwards. Stops if is at the start of a copy of
'string' where characters are compared without case sensitivity. Stops 'string' where characters are compared without case sensitivity. Stops
...@@ -921,7 +920,6 @@ dict_scan_to( ...@@ -921,7 +920,6 @@ dict_scan_to(
/* out: scanned up to this */ /* out: scanned up to this */
const char* ptr, /* in: scan from */ const char* ptr, /* in: scan from */
const char* string);/* in: look for this */ const char* string);/* in: look for this */
/* Buffers for storing detailed information about the latest foreign key /* Buffers for storing detailed information about the latest foreign key
and unique key errors */ and unique key errors */
extern FILE* dict_foreign_err_file; extern FILE* dict_foreign_err_file;
......
...@@ -505,6 +505,22 @@ pars_info_add_int4_literal( ...@@ -505,6 +505,22 @@ pars_info_add_int4_literal(
lint val); /* in: value */ lint val); /* in: value */
/******************************************************************** /********************************************************************
Equivalent to:
char buf[8];
mach_write_to_8(buf, val);
pars_info_add_literal(info, name, buf, 8, DATA_BINARY, 0);
except that the buffer is dynamically allocated from the info struct's
heap. */
void
pars_info_add_dulint_literal(
/*=========================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: name */
dulint val); /* in: value */
/********************************************************************
Add user function. */ Add user function. */
void void
......
...@@ -331,8 +331,15 @@ void ...@@ -331,8 +331,15 @@ void
que_node_print_info( que_node_print_info(
/*================*/ /*================*/
que_node_t* node); /* in: query graph node */ que_node_t* node); /* in: query graph node */
/*************************************************************************
Evaluate the given SQL */
ulint
que_eval_sql(
/*=========*/
pars_info_t* info, /* out: error code or DB_SUCCESS */
const char* sql, /* in: info struct, or NULL */
trx_t* trx); /* in: trx */
/* Query graph query thread node: the fields are protected by the kernel /* Query graph query thread node: the fields are protected by the kernel
mutex with the exceptions named below */ mutex with the exceptions named below */
......
...@@ -2016,6 +2016,30 @@ pars_info_add_int4_literal( ...@@ -2016,6 +2016,30 @@ pars_info_add_int4_literal(
pars_info_add_literal(info, name, buf, 4, DATA_INT, 0); pars_info_add_literal(info, name, buf, 4, DATA_INT, 0);
} }
/********************************************************************
Equivalent to:
char buf[8];
mach_write_to_8(buf, val);
pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0);
except that the buffer is dynamically allocated from the info struct's
heap. */
void
pars_info_add_dulint_literal(
/*=========================*/
pars_info_t* info, /* in: info struct */
const char* name, /* in: name */
dulint val) /* in: value */
{
byte* buf = mem_heap_alloc(info->heap, 8);
mach_write_to_8(buf, val);
pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0);
}
/******************************************************************** /********************************************************************
Add user function. */ Add user function. */
......
...@@ -25,6 +25,7 @@ Created 5/27/1996 Heikki Tuuri ...@@ -25,6 +25,7 @@ Created 5/27/1996 Heikki Tuuri
#include "log0log.h" #include "log0log.h"
#include "eval0proc.h" #include "eval0proc.h"
#include "eval0eval.h" #include "eval0eval.h"
#include "pars0types.h"
#define QUE_PARALLELIZE_LIMIT (64 * 256 * 256 * 256) #define QUE_PARALLELIZE_LIMIT (64 * 256 * 256 * 256)
#define QUE_ROUND_ROBIN_LIMIT (64 * 256 * 256 * 256) #define QUE_ROUND_ROBIN_LIMIT (64 * 256 * 256 * 256)
...@@ -1365,3 +1366,33 @@ loop: ...@@ -1365,3 +1366,33 @@ loop:
goto loop; goto loop;
} }
/*************************************************************************
Evaluate the given SQL */
ulint
que_eval_sql(
/*=========*/
pars_info_t* info, /* out: error code or DB_SUCCESS */
const char* sql, /* in: info struct, or NULL */
trx_t* trx) /* in: trx */
{
que_thr_t* thr;
que_t* graph;
graph = pars_sql(info, sql);
ut_a(graph);
graph->trx = trx;
trx->graph = NULL;
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
ut_a(thr = que_fork_start_command(graph));
que_run_threads(thr);
que_graph_free(graph);
return(trx->error_state);
}
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