Commit cb9f3048 authored by unknown's avatar unknown

Merge marko@build.mysql.com:/home/bk/mysql-4.0

into hundin.mysql.fi:/home/marko/l/mysql-4.0

parents 233c422f 713ca805
...@@ -1231,7 +1231,6 @@ dnl circular references. ...@@ -1231,7 +1231,6 @@ dnl circular references.
\$(top_builddir)/innobase/page/libpage.a\ \$(top_builddir)/innobase/page/libpage.a\
\$(top_builddir)/innobase/rem/librem.a\ \$(top_builddir)/innobase/rem/librem.a\
\$(top_builddir)/innobase/thr/libthr.a\ \$(top_builddir)/innobase/thr/libthr.a\
\$(top_builddir)/innobase/com/libcom.a\
\$(top_builddir)/innobase/sync/libsync.a\ \$(top_builddir)/innobase/sync/libsync.a\
\$(top_builddir)/innobase/data/libdata.a\ \$(top_builddir)/innobase/data/libdata.a\
\$(top_builddir)/innobase/mach/libmach.a\ \$(top_builddir)/innobase/mach/libmach.a\
......
...@@ -25,13 +25,13 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \ ...@@ -25,13 +25,13 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
dict0mem.ic dict0types.h dyn0dyn.h dyn0dyn.ic eval0eval.h \ dict0mem.ic dict0types.h dyn0dyn.h dyn0dyn.ic eval0eval.h \
eval0eval.ic eval0proc.h eval0proc.ic fil0fil.h fsp0fsp.h \ eval0eval.ic eval0proc.h eval0proc.ic fil0fil.h fsp0fsp.h \
fsp0fsp.ic fut0fut.h fut0fut.ic fut0lst.h fut0lst.ic \ fsp0fsp.ic fut0fut.h fut0fut.ic fut0lst.h fut0lst.ic \
ha0ha.h ha0ha.ic hash0hash.h hash0hash.ic ib_odbc.h \ ha0ha.h ha0ha.ic hash0hash.h hash0hash.ic \
ibuf0ibuf.h ibuf0ibuf.ic ibuf0types.h lock0lock.h \ ibuf0ibuf.h ibuf0ibuf.ic ibuf0types.h lock0lock.h \
lock0lock.ic lock0types.h log0log.h log0log.ic log0recv.h \ lock0lock.ic lock0types.h log0log.h log0log.ic log0recv.h \
log0recv.ic mach0data.h mach0data.ic makefilewin.i \ log0recv.ic mach0data.h mach0data.ic makefilewin.i \
mem0dbg.h mem0dbg.ic mem0mem.h mem0mem.ic mem0pool.h \ mem0dbg.h mem0dbg.ic mem0mem.h mem0mem.ic mem0pool.h \
mem0pool.ic mtr0log.h mtr0log.ic mtr0mtr.h mtr0mtr.ic \ mem0pool.ic mtr0log.h mtr0log.ic mtr0mtr.h mtr0mtr.ic \
mtr0types.h odbc0odbc.h os0file.h os0proc.h os0proc.ic \ mtr0types.h os0file.h os0proc.h os0proc.ic \
os0shm.h os0shm.ic os0sync.h os0sync.ic os0thread.h \ os0shm.h os0shm.ic os0sync.h os0sync.ic os0thread.h \
os0thread.ic page0cur.h page0cur.ic page0page.h \ os0thread.ic page0cur.h page0cur.ic page0page.h \
page0page.ic page0types.h pars0grm.h pars0opt.h \ page0page.ic page0types.h pars0grm.h pars0opt.h \
......
/******************************************************
Innobase ODBC client library header; this is equivalent to
the standard sql.h ODBC header file
(c) 1998 Innobase Oy
Created 2/22/1998 Heikki Tuuri
*******************************************************/
#ifndef ib_odbc_h
#define ib_odbc_h
typedef unsigned char UCHAR;
typedef signed char SCHAR;
typedef long int SDWORD;
typedef short int SWORD;
typedef unsigned long int UDWORD;
typedef unsigned short int UWORD;
typedef void* PTR;
typedef void* HENV;
typedef void* HDBC;
typedef void* HSTMT;
typedef signed short RETCODE;
/* RETCODEs */
#define SQL_NO_DATA_FOUND (-3)
#define SQL_INVALID_HANDLE (-2)
#define SQL_ERROR (-1)
#define SQL_SUCCESS 0
/* Standard SQL datatypes, using ANSI type numbering */
#define SQL_CHAR 1
#define SQL_INTEGER 4
#define SQL_VARCHAR 12
/* C datatype to SQL datatype mapping */
#define SQL_C_CHAR SQL_CHAR
#define SQL_C_LONG SQL_INTEGER
/* Special length value */
#define SQL_NULL_DATA (-1)
#define SQL_PARAM_INPUT 1
#define SQL_PARAM_OUTPUT 4
/* Null handles */
#define SQL_NULL_HENV NULL
#define SQL_NULL_HDBC NULL
#define SQL_NULL_HSTM NULL
/**************************************************************************
Allocates an SQL environment. */
RETCODE
SQLAllocEnv(
/*========*/
/* out: SQL_SUCCESS */
HENV* phenv); /* out: pointer to an environment handle */
/**************************************************************************
Allocates an SQL connection. */
RETCODE
SQLAllocConnect(
/*============*/
/* out: SQL_SUCCESS */
HENV henv, /* in: pointer to an environment handle */
HDBC* phdbc); /* out: pointer to a connection handle */
/**************************************************************************
Allocates an SQL statement. */
RETCODE
SQLAllocStmt(
/*=========*/
HDBC hdbc, /* in: SQL connection */
HSTMT* phstmt); /* out: pointer to a statement handle */
/**************************************************************************
Connects to a database server process (establishes a connection and a
session). */
RETCODE
SQLConnect(
/*=======*/
/* out: SQL_SUCCESS */
HDBC hdbc, /* in: SQL connection handle */
UCHAR* szDSN, /* in: data source name (server name) */
SWORD cbDSN, /* in: data source name length */
UCHAR* szUID, /* in: user name */
SWORD cbUID, /* in: user name length */
UCHAR* szAuthStr, /* in: password */
SWORD cbAuthStr); /* in: password length */
/**************************************************************************
Makes the server to parse and optimize an SQL string. */
RETCODE
SQLPrepare(
/*=======*/
/* out: SQL_SUCCESS */
HSTMT hstmt, /* in: statement handle */
UCHAR* szSqlStr, /* in: SQL string */
SDWORD cbSqlStr); /* in: SQL string length */
/**************************************************************************
Binds a parameter in a prepared statement. */
RETCODE
SQLBindParameter(
/*=============*/
/* out: SQL_SUCCESS */
HSTMT hstmt, /* in: statement handle */
UWORD ipar, /* in: parameter index, starting from 1 */
SWORD fParamType, /* in: SQL_PARAM_INPUT or SQL_PARAM_OUTPUT */
SWORD fCType, /* in: SQL_C_CHAR, ... */
SWORD fSqlType, /* in: SQL_CHAR, ... */
UDWORD cbColDef, /* in: precision: ignored */
SWORD ibScale, /* in: scale: ignored */
PTR rgbValue, /* in: pointer to a buffer for the data */
SDWORD cbValueMax, /* in: buffer size */
SDWORD* pcbValue); /* in: pointer to a buffer for the data
length or SQL_NULL_DATA */
/**************************************************************************
Executes a prepared statement where all parameters have been bound. */
RETCODE
SQLExecute(
/*=======*/
/* out: SQL_SUCCESS or SQL_ERROR */
HSTMT hstmt); /* in: statement handle */
/**************************************************************************
Queries an error message. */
RETCODE
SQLError(
/*=====*/
/* out: SQL_SUCCESS or SQL_NO_DATA_FOUND */
HENV henv, /* in: SQL_NULL_HENV */
HDBC hdbc, /* in: SQL_NULL_HDBC */
HSTMT hstmt, /* in: statement handle */
UCHAR* szSqlState, /* in/out: SQLSTATE as a null-terminated string,
(currently, always == "S1000") */
SDWORD* pfNativeError, /* out: native error code */
UCHAR* szErrorMsg, /* in/out: buffer for an error message as a
null-terminated string */
SWORD cbErrorMsgMax, /* in: buffer size for szErrorMsg */
SWORD* pcbErrorMsg); /* out: error message length */
#endif
/******************************************************
Innobase ODBC client library additional header
(c) 1998 Innobase Oy
Created 2/22/1998 Heikki Tuuri
*******************************************************/
#ifndef odbc0odbc_h
#define odbc0odbc_h
#include "ib_odbc.h"
/* Datagram size in communications */
#define ODBC_DATAGRAM_SIZE 8192
/* Communication address maximum length in bytes */
#define ODBC_ADDRESS_SIZE COM_MAX_ADDR_LEN
#endif
...@@ -21,7 +21,9 @@ extern int yydebug; ...@@ -21,7 +21,9 @@ extern int yydebug;
/* If the following is set TRUE, the lexer will print the SQL string /* If the following is set TRUE, the lexer will print the SQL string
as it tokenizes it */ as it tokenizes it */
#ifdef UNIV_SQL_DEBUG
extern ibool pars_print_lexed; extern ibool pars_print_lexed;
#endif /* UNIV_SQL_DEBUG */
/* Global variable used while parsing a single procedure or query : the code is /* Global variable used while parsing a single procedure or query : the code is
NOT re-entrant */ NOT re-entrant */
...@@ -390,41 +392,18 @@ pars_procedure_definition( ...@@ -390,41 +392,18 @@ pars_procedure_definition(
table */ table */
sym_node_t* param_list, /* in: parameter declaration list */ sym_node_t* param_list, /* in: parameter declaration list */
que_node_t* stat_list); /* in: statement list */ que_node_t* stat_list); /* in: statement list */
/*****************************************************************
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 */
/*****************************************************************
Writes stored procedure output parameter values to a buffer. */
ulint
pars_proc_write_output_params_to_buf(
/*=================================*/
byte* buf, /* in: buffer which must be big enough */
que_t* graph); /* in: query graph which contains a stored procedure */
/***************************************************************** /*****************************************************************
Parses a stored procedure call, when this is not within another stored 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* que_fork_t*
pars_stored_procedure_call( pars_stored_procedure_call(
/*=======================*/ /*=======================*/
/* out: query graph */ /* out: query graph */
sym_node_t* sym_node); /* in: stored procedure name */ sym_node_t* sym_node); /* in: stored procedure name */
/*****************************************************************
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 */
/********************************************************************** /**********************************************************************
Completes a query graph by adding query thread and fork nodes Completes a query graph by adding query thread and fork nodes
above it and prepares the graph for running. The fork created is of above it and prepares the graph for running. The fork created is of
......
...@@ -29,13 +29,14 @@ on 1/27/1998 */ ...@@ -29,13 +29,14 @@ on 1/27/1998 */
#include "trx0trx.h" #include "trx0trx.h"
#include "trx0roll.h" #include "trx0roll.h"
#include "lock0lock.h" #include "lock0lock.h"
#include "odbc0odbc.h"
#include "eval0eval.h" #include "eval0eval.h"
#ifdef UNIV_SQL_DEBUG
/* If the following is set TRUE, the lexer will print the SQL string /* If the following is set TRUE, the lexer will print the SQL string
as it tokenizes it */ as it tokenizes it */
ibool pars_print_lexed = FALSE; ibool pars_print_lexed = FALSE;
#endif /* UNIV_SQL_DEBUG */
/* Global variable used while parsing a single procedure or query : the code is /* Global variable used while parsing a single procedure or query : the code is
NOT re-entrant */ NOT re-entrant */
...@@ -389,7 +390,7 @@ pars_resolve_exp_variables_and_types( ...@@ -389,7 +390,7 @@ pars_resolve_exp_variables_and_types(
} }
if (!node) { if (!node) {
printf("PARSER ERROR: Unresolved identifier %s\n", fprintf(stderr, "PARSER ERROR: Unresolved identifier %s\n",
sym_node->name); sym_node->name);
} }
...@@ -521,25 +522,6 @@ pars_resolve_exp_list_columns( ...@@ -521,25 +522,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. */ Retrieves the table definition for a table name id. */
static static
...@@ -1662,216 +1644,19 @@ pars_procedure_definition( ...@@ -1662,216 +1644,19 @@ pars_procedure_definition(
/***************************************************************** /*****************************************************************
Parses a stored procedure call, when this is not within another stored 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* que_fork_t*
pars_stored_procedure_call( pars_stored_procedure_call(
/*=======================*/ /*=======================*/
/* out: query graph */ /* 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; ut_error;
call_node_t* call_node; return(NULL);
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);
}
/*****************************************************************
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));
} }
/***************************************************************** /*****************************************************************
...@@ -1886,13 +1671,12 @@ pars_get_lex_chars( ...@@ -1886,13 +1671,12 @@ pars_get_lex_chars(
in the buffer */ in the buffer */
{ {
int len; int len;
char print_buf[16];
len = pars_sym_tab_global->string_len len = pars_sym_tab_global->string_len
- pars_sym_tab_global->next_char_pos; - pars_sym_tab_global->next_char_pos;
if (len == 0) { if (len == 0) {
#ifdef YYDEBUG #ifdef YYDEBUG
/* printf("SQL string ends\n"); */ /* fputs("SQL string ends\n", stderr); */
#endif #endif
*result = 0; *result = 0;
...@@ -1903,18 +1687,18 @@ pars_get_lex_chars( ...@@ -1903,18 +1687,18 @@ pars_get_lex_chars(
len = max_size; len = max_size;
} }
#ifdef UNIV_SQL_DEBUG
if (pars_print_lexed) { if (pars_print_lexed) {
if (len >= 5) { if (len >= 5) {
len = 5; len = 5;
} }
ut_memcpy(print_buf, pars_sym_tab_global->sql_string + fwrite(pars_sym_tab_global->sql_string +
pars_sym_tab_global->next_char_pos, len); pars_sym_tab_global->next_char_pos,
print_buf[len] = '\0'; 1, len, stderr);
printf("%s", print_buf);
} }
#endif /* UNIV_SQL_DEBUG */
ut_memcpy(buf, pars_sym_tab_global->sql_string + ut_memcpy(buf, pars_sym_tab_global->sql_string +
pars_sym_tab_global->next_char_pos, len); pars_sym_tab_global->next_char_pos, len);
...@@ -1944,7 +1728,7 @@ yyerror( ...@@ -1944,7 +1728,7 @@ yyerror(
{ {
ut_ad(s); ut_ad(s);
printf("PARSER ERROR: Syntax error in SQL string\n"); fputs("PARSER ERROR: Syntax error in SQL string\n", stderr);
ut_error; ut_error;
} }
...@@ -1968,10 +1752,10 @@ pars_sql( ...@@ -1968,10 +1752,10 @@ pars_sql(
heap = mem_heap_create(256); heap = mem_heap_create(256);
#ifdef UNIV_SYNC_DEBUG
/* Currently, the parser is not reentrant: */ /* Currently, the parser is not reentrant: */
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
pars_sym_tab_global = sym_tab_create(heap); pars_sym_tab_global = sym_tab_create(heap);
len = ut_strlen(str); len = ut_strlen(str);
...@@ -1996,7 +1780,7 @@ pars_sql( ...@@ -1996,7 +1780,7 @@ pars_sql(
graph->sym_tab = pars_sym_tab_global; 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); return(graph);
} }
......
...@@ -37,7 +37,6 @@ Created 10/8/1995 Heikki Tuuri ...@@ -37,7 +37,6 @@ Created 10/8/1995 Heikki Tuuri
#include "que0que.h" #include "que0que.h"
#include "srv0que.h" #include "srv0que.h"
#include "log0recv.h" #include "log0recv.h"
#include "odbc0odbc.h"
#include "pars0pars.h" #include "pars0pars.h"
#include "usr0sess.h" #include "usr0sess.h"
#include "lock0lock.h" #include "lock0lock.h"
......
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