Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
727354ae
Commit
727354ae
authored
Apr 01, 2006
by
osku
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for bound literals in the SQL parser.
parent
d643d731
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1859 additions
and
1670 deletions
+1859
-1670
include/pars0grm.h
include/pars0grm.h
+176
-172
include/pars0pars.h
include/pars0pars.h
+26
-5
include/pars0sym.h
include/pars0sym.h
+10
-0
include/pars0types.h
include/pars0types.h
+1
-0
pars/lexyy.c
pars/lexyy.c
+463
-445
pars/pars0grm.c
pars/pars0grm.c
+900
-876
pars/pars0grm.h
pars/pars0grm.h
+176
-172
pars/pars0grm.y
pars/pars0grm.y
+4
-0
pars/pars0lex.l
pars/pars0lex.l
+11
-0
pars/pars0pars.c
pars/pars0pars.c
+26
-0
pars/pars0sym.c
pars/pars0sym.c
+66
-0
No files found.
include/pars0grm.h
View file @
727354ae
This diff is collapsed.
Click to expand it.
include/pars0pars.h
View file @
727354ae
...
...
@@ -450,14 +450,26 @@ pars_info_get_user_func(
pars_info_t
*
info
,
/* in: info struct */
const
char
*
name
);
/* in: function name to find*/
/********************************************************************
Get bound literal with the given name.*/
pars_bound_lit_t
*
pars_info_get_bound_lit
(
/*====================*/
/* out: bound literal, or NULL if
not found */
pars_info_t
*
info
,
/* in: info struct */
const
char
*
name
);
/* in: bound literal name to find */
/* Extra information (possibly) supplied for pars_sql(). */
/* Extra information supplied for pars_sql(). All data is owned by the user
who's responsible for freeing them as necessary.*/
struct
pars_info_struct
{
pars_user_func_t
*
funcs
;
/* User functions, owned by
the user, who's responsible
for freeing them as
necessary. */
pars_user_func_t
*
funcs
;
/* user functions */
ulint
n_funcs
;
/* number of user functions */
pars_bound_lit_t
*
bound_lits
;
/* bound literals */
ulint
n_bound_lits
;
/* number of bound literals */
};
/* Type of the user functions. The first argument is always InnoDB-supplied
...
...
@@ -473,6 +485,15 @@ struct pars_user_func_struct {
void
*
arg
;
/* user-supplied argument */
};
/* Bound literal. */
struct
pars_bound_lit_struct
{
const
char
*
name
;
/* name */
void
*
address
;
/* address */
ulint
length
;
/* length of data */
ulint
type
;
/* type, e.g. DATA_FIXBINARY */
ulint
prtype
;
/* precise type, e.g. DATA_UNSIGNED */
};
/* Struct used to denote a reserved word in a parsing tree */
struct
pars_res_word_struct
{
int
code
;
/* the token code for the reserved word from
...
...
include/pars0sym.h
View file @
727354ae
...
...
@@ -54,6 +54,16 @@ sym_tab_add_str_lit(
it */
ulint
len
);
/* in: string length */
/**********************************************************************
Add a bound literal to a symbol table. */
sym_node_t
*
sym_tab_add_bound_lit
(
/*==================*/
/* out: symbol table node */
sym_tab_t
*
sym_tab
,
/* in: symbol table */
const
char
*
name
,
/* in: name of bound literal */
ulint
*
lit_type
);
/* out: type of literal (PARS_*_LIT) */
/**********************************************************************
Adds an SQL null literal to a symbol table. */
sym_node_t
*
...
...
include/pars0types.h
View file @
727354ae
...
...
@@ -11,6 +11,7 @@ Created 1/11/1998 Heikki Tuuri
typedef
struct
pars_info_struct
pars_info_t
;
typedef
struct
pars_user_func_struct
pars_user_func_t
;
typedef
struct
pars_bound_lit_struct
pars_bound_lit_t
;
typedef
struct
sym_node_struct
sym_node_t
;
typedef
struct
sym_tab_struct
sym_tab_t
;
typedef
struct
pars_res_word_struct
pars_res_word_t
;
...
...
pars/lexyy.c
View file @
727354ae
This diff is collapsed.
Click to expand it.
pars/pars0grm.c
View file @
727354ae
This diff is collapsed.
Click to expand it.
pars/pars0grm.h
View file @
727354ae
This diff is collapsed.
Click to expand it.
pars/pars0grm.y
View file @
727354ae
...
...
@@ -33,6 +33,8 @@ yylex(void);
%token PARS_INT_LIT
%token PARS_FLOAT_LIT
%token PARS_STR_LIT
%token PARS_FIXBINARY_LIT
%token PARS_BLOB_LIT
%token PARS_NULL_LIT
%token PARS_ID_TOKEN
%token PARS_AND_TOKEN
...
...
@@ -169,6 +171,8 @@ exp:
| PARS_INT_LIT { $$ = $1;}
| PARS_FLOAT_LIT { $$ = $1;}
| PARS_STR_LIT { $$ = $1;}
| PARS_FIXBINARY_LIT { $$ = $1;}
| PARS_BLOB_LIT { $$ = $1;}
| PARS_NULL_LIT { $$ = $1;}
| PARS_SQL_TOKEN { $$ = $1;}
| exp '+' exp { $$ = pars_op('+', $1, $3); }
...
...
pars/pars0lex.l
View file @
727354ae
...
...
@@ -83,6 +83,8 @@ string_append(
DIGIT [0-9]
ID [a-z_A-Z][a-z_A-Z0-9]*
BOUND_LIT \:[a-z_A-Z0-9]+
%x comment
%x quoted
%x id
...
...
@@ -100,6 +102,15 @@ ID [a-z_A-Z][a-z_A-Z0-9]*
return(PARS_FLOAT_LIT);
}
{BOUND_LIT} {
ulint type;
yylval = sym_tab_add_bound_lit(pars_sym_tab_global,
yytext + 1, &type);
return(type);
}
"'" {
/* Quoted character string literals are handled in an explicit
start state 'quoted'. This state is entered and the buffer for
...
...
pars/pars0pars.c
View file @
727354ae
...
...
@@ -1937,3 +1937,29 @@ pars_info_get_user_func(
return
(
NULL
);
}
/********************************************************************
Get bound literal with the given name.*/
pars_bound_lit_t
*
pars_info_get_bound_lit
(
/*====================*/
/* out: bound literal, or NULL if
not found */
pars_info_t
*
info
,
/* in: info struct */
const
char
*
name
)
/* in: bound literal name to find */
{
ulint
i
;
if
(
!
info
)
{
return
(
NULL
);
}
for
(
i
=
0
;
i
<
info
->
n_bound_lits
;
i
++
)
{
if
(
strcmp
(
info
->
bound_lits
[
i
].
name
,
name
)
==
0
)
{
return
(
&
info
->
bound_lits
[
i
]);
}
}
return
(
NULL
);
}
pars/pars0sym.c
View file @
727354ae
...
...
@@ -15,6 +15,7 @@ Created 12/15/1997 Heikki Tuuri
#include "mem0mem.h"
#include "data0type.h"
#include "data0data.h"
#include "pars0grm.h"
#include "pars0pars.h"
#include "que0que.h"
#include "eval0eval.h"
...
...
@@ -165,6 +166,71 @@ sym_tab_add_str_lit(
return
(
node
);
}
/**********************************************************************
Add a bound literal to a symbol table. */
sym_node_t
*
sym_tab_add_bound_lit
(
/*==================*/
/* out: symbol table node */
sym_tab_t
*
sym_tab
,
/* in: symbol table */
const
char
*
name
,
/* in: name of bound literal */
ulint
*
lit_type
)
/* out: type of literal (PARS_*_LIT) */
{
sym_node_t
*
node
;
pars_bound_lit_t
*
blit
;
ulint
len
;
blit
=
pars_info_get_bound_lit
(
sym_tab
->
info
,
name
);
ut_a
(
blit
);
ut_a
(
blit
->
length
>
0
);
node
=
mem_heap_alloc
(
sym_tab
->
heap
,
sizeof
(
sym_node_t
));
node
->
common
.
type
=
QUE_NODE_SYMBOL
;
node
->
resolved
=
TRUE
;
node
->
token_type
=
SYM_LIT
;
node
->
indirection
=
NULL
;
switch
(
blit
->
type
)
{
case
DATA_FIXBINARY
:
len
=
blit
->
length
;
*
lit_type
=
PARS_FIXBINARY_LIT
;
break
;
case
DATA_BLOB
:
len
=
0
;
*
lit_type
=
PARS_BLOB_LIT
;
break
;
case
DATA_INT
:
ut_a
(
blit
->
length
<=
8
);
len
=
blit
->
length
;
*
lit_type
=
PARS_INT_LIT
;
break
;
default:
ut_error
;
}
dtype_set
(
&
(
node
->
common
.
val
.
type
),
blit
->
type
,
blit
->
prtype
,
len
,
0
);
dfield_set_data
(
&
(
node
->
common
.
val
),
blit
->
address
,
blit
->
length
);
node
->
common
.
val_buf_size
=
0
;
node
->
prefetch_buf
=
NULL
;
node
->
cursor_def
=
NULL
;
UT_LIST_ADD_LAST
(
sym_list
,
sym_tab
->
sym_list
,
node
);
node
->
sym_table
=
sym_tab
;
return
(
node
);
}
/**********************************************************************
Adds an SQL null literal to a symbol table. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment