~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/eval/eval0eval.c

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file eval/eval0eval.c
 
1
/******************************************************
21
2
SQL evaluator: evaluates simple data structures, like expressions, in
22
3
a query graph
23
4
 
 
5
(c) 1997 Innobase Oy
 
6
 
24
7
Created 12/29/1997 Heikki Tuuri
25
8
*******************************************************/
26
9
 
33
16
#include "data0data.h"
34
17
#include "row0sel.h"
35
18
 
36
 
/** The RND function seed */
 
19
/* The RND function seed */
37
20
static ulint    eval_rnd        = 128367121;
38
21
 
39
 
/** Dummy adress used when we should allocate a buffer of size 0 in
40
 
eval_node_alloc_val_buf */
 
22
/* Dummy adress used when we should allocate a buffer of size 0 in
 
23
the function below */
41
24
 
42
25
static byte     eval_dummy;
43
26
 
44
 
/*****************************************************************//**
 
27
/*********************************************************************
45
28
Allocate a buffer from global dynamic memory for a value of a que_node.
46
29
NOTE that this memory must be explicitly freed when the query graph is
47
30
freed. If the node already has an allocated buffer, that buffer is freed
48
31
here. NOTE that this is the only function where dynamic memory should be
49
 
allocated for a query node val field.
50
 
@return pointer to allocated buffer */
 
32
allocated for a query node val field. */
51
33
UNIV_INTERN
52
34
byte*
53
35
eval_node_alloc_val_buf(
54
36
/*====================*/
55
 
        que_node_t*     node,   /*!< in: query graph node; sets the val field
 
37
                                /* out: pointer to allocated buffer */
 
38
        que_node_t*     node,   /* in: query graph node; sets the val field
56
39
                                data field to point to the new buffer, and
57
40
                                len field equal to size */
58
 
        ulint           size)   /*!< in: buffer size */
 
41
        ulint           size)   /* in: buffer size */
59
42
{
60
43
        dfield_t*       dfield;
61
44
        byte*           data;
84
67
        return(data);
85
68
}
86
69
 
87
 
/*****************************************************************//**
 
70
/*********************************************************************
88
71
Free the buffer from global dynamic memory for a value of a que_node,
89
72
if it has been allocated in the above function. The freeing for pushed
90
73
column values is done in sel_col_prefetch_buf_free. */
92
75
void
93
76
eval_node_free_val_buf(
94
77
/*===================*/
95
 
        que_node_t*     node)   /*!< in: query graph node */
 
78
        que_node_t*     node)   /* in: query graph node */
96
79
{
97
80
        dfield_t*       dfield;
98
81
        byte*           data;
111
94
        }
112
95
}
113
96
 
114
 
/*****************************************************************//**
115
 
Evaluates a comparison node.
116
 
@return the result of the comparison */
 
97
/*********************************************************************
 
98
Evaluates a comparison node. */
117
99
UNIV_INTERN
118
100
ibool
119
101
eval_cmp(
120
102
/*=====*/
121
 
        func_node_t*    cmp_node)       /*!< in: comparison node */
 
103
                                        /* out: the result of the comparison */
 
104
        func_node_t*    cmp_node)       /* in: comparison node */
122
105
{
123
106
        que_node_t*     arg1;
124
107
        que_node_t*     arg2;
170
153
        return(val);
171
154
}
172
155
 
173
 
/*****************************************************************//**
 
156
/*********************************************************************
174
157
Evaluates a logical operation node. */
175
158
UNIV_INLINE
176
159
void
177
160
eval_logical(
178
161
/*=========*/
179
 
        func_node_t*    logical_node)   /*!< in: logical operation node */
 
162
        func_node_t*    logical_node)   /* in: logical operation node */
180
163
{
181
164
        que_node_t*     arg1;
182
165
        que_node_t*     arg2;
211
194
        eval_node_set_ibool_val(logical_node, val);
212
195
}
213
196
 
214
 
/*****************************************************************//**
 
197
/*********************************************************************
215
198
Evaluates an arithmetic operation node. */
216
199
UNIV_INLINE
217
200
void
218
201
eval_arith(
219
202
/*=======*/
220
 
        func_node_t*    arith_node)     /*!< in: arithmetic operation node */
 
203
        func_node_t*    arith_node)     /* in: arithmetic operation node */
221
204
{
222
205
        que_node_t*     arg1;
223
206
        que_node_t*     arg2;
255
238
        eval_node_set_int_val(arith_node, val);
256
239
}
257
240
 
258
 
/*****************************************************************//**
 
241
/*********************************************************************
259
242
Evaluates an aggregate operation node. */
260
243
UNIV_INLINE
261
244
void
262
245
eval_aggregate(
263
246
/*===========*/
264
 
        func_node_t*    node)   /*!< in: aggregate operation node */
 
247
        func_node_t*    node)   /* in: aggregate operation node */
265
248
{
266
249
        que_node_t*     arg;
267
250
        lint            val;
289
272
        eval_node_set_int_val(node, val);
290
273
}
291
274
 
292
 
/*****************************************************************//**
 
275
/*********************************************************************
293
276
Evaluates a predefined function node where the function is not relevant
294
277
in benchmarks. */
295
278
static
296
279
void
297
280
eval_predefined_2(
298
281
/*==============*/
299
 
        func_node_t*    func_node)      /*!< in: predefined function node */
 
282
        func_node_t*    func_node)      /* in: predefined function node */
300
283
{
301
284
        que_node_t*     arg;
302
285
        que_node_t*     arg1;
376
359
        }
377
360
}
378
361
 
379
 
/*****************************************************************//**
 
362
/*********************************************************************
380
363
Evaluates a notfound-function node. */
381
364
UNIV_INLINE
382
365
void
383
366
eval_notfound(
384
367
/*==========*/
385
 
        func_node_t*    func_node)      /*!< in: function node */
 
368
        func_node_t*    func_node)      /* in: function node */
386
369
{
387
370
        que_node_t*     arg1;
388
371
        que_node_t*     arg2;
418
401
        eval_node_set_ibool_val(func_node, ibool_val);
419
402
}
420
403
 
421
 
/*****************************************************************//**
 
404
/*********************************************************************
422
405
Evaluates a substr-function node. */
423
406
UNIV_INLINE
424
407
void
425
408
eval_substr(
426
409
/*========*/
427
 
        func_node_t*    func_node)      /*!< in: function node */
 
410
        func_node_t*    func_node)      /* in: function node */
428
411
{
429
412
        que_node_t*     arg1;
430
413
        que_node_t*     arg2;
451
434
        dfield_set_data(dfield, str1 + len1, len2);
452
435
}
453
436
 
454
 
/*****************************************************************//**
 
437
/*********************************************************************
455
438
Evaluates a replstr-procedure node. */
456
439
static
457
440
void
458
441
eval_replstr(
459
442
/*=========*/
460
 
        func_node_t*    func_node)      /*!< in: function node */
 
443
        func_node_t*    func_node)      /* in: function node */
461
444
{
462
445
        que_node_t*     arg1;
463
446
        que_node_t*     arg2;
491
474
        ut_memcpy(str1 + len1, str2, len2);
492
475
}
493
476
 
494
 
/*****************************************************************//**
 
477
/*********************************************************************
495
478
Evaluates an instr-function node. */
496
479
static
497
480
void
498
481
eval_instr(
499
482
/*=======*/
500
 
        func_node_t*    func_node)      /*!< in: function node */
 
483
        func_node_t*    func_node)      /* in: function node */
501
484
{
502
485
        que_node_t*     arg1;
503
486
        que_node_t*     arg2;
563
546
        eval_node_set_int_val(func_node, int_val);
564
547
}
565
548
 
566
 
/*****************************************************************//**
 
549
/*********************************************************************
567
550
Evaluates a predefined function node. */
568
551
UNIV_INLINE
569
552
void
570
553
eval_binary_to_number(
571
554
/*==================*/
572
 
        func_node_t*    func_node)      /*!< in: function node */
 
555
        func_node_t*    func_node)      /* in: function node */
573
556
{
574
557
        que_node_t*     arg1;
575
558
        dfield_t*       dfield;
601
584
        eval_node_copy_and_alloc_val(func_node, str2, 4);
602
585
}
603
586
 
604
 
/*****************************************************************//**
 
587
/*********************************************************************
605
588
Evaluates a predefined function node. */
606
589
static
607
590
void
608
591
eval_concat(
609
592
/*========*/
610
 
        func_node_t*    func_node)      /*!< in: function node */
 
593
        func_node_t*    func_node)      /* in: function node */
611
594
{
612
595
        que_node_t*     arg;
613
596
        dfield_t*       dfield;
643
626
        }
644
627
}
645
628
 
646
 
/*****************************************************************//**
 
629
/*********************************************************************
647
630
Evaluates a predefined function node. If the first argument is an integer,
648
631
this function looks at the second argument which is the integer length in
649
632
bytes, and converts the integer to a VARCHAR.
653
636
void
654
637
eval_to_binary(
655
638
/*===========*/
656
 
        func_node_t*    func_node)      /*!< in: function node */
 
639
        func_node_t*    func_node)      /* in: function node */
657
640
{
658
641
        que_node_t*     arg1;
659
642
        que_node_t*     arg2;
691
674
        dfield_set_data(dfield, str1 + (4 - len1), len1);
692
675
}
693
676
 
694
 
/*****************************************************************//**
 
677
/*********************************************************************
695
678
Evaluates a predefined function node. */
696
679
UNIV_INLINE
697
680
void
698
681
eval_predefined(
699
682
/*============*/
700
 
        func_node_t*    func_node)      /*!< in: function node */
 
683
        func_node_t*    func_node)      /* in: function node */
701
684
{
702
685
        que_node_t*     arg1;
703
686
        lint            int_val;
783
766
        eval_node_set_int_val(func_node, int_val);
784
767
}
785
768
 
786
 
/*****************************************************************//**
 
769
/*********************************************************************
787
770
Evaluates a function node. */
788
771
UNIV_INTERN
789
772
void
790
773
eval_func(
791
774
/*======*/
792
 
        func_node_t*    func_node)      /*!< in: function node */
 
775
        func_node_t*    func_node)      /* in: function node */
793
776
{
794
777
        que_node_t*     arg;
795
778
        ulint           class;