Merge lp:~stewart/drizzle/jay-and-stewart-remove-pack_flag into lp:~drizzle-trunk/drizzle/development

Proposed by Stewart Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp:~stewart/drizzle/jay-and-stewart-remove-pack_flag
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 2218 lines
33 files modified
drizzled/common.h (+0/-1)
drizzled/create_field.cc (+10/-6)
drizzled/create_field.h (+1/-2)
drizzled/definitions.h (+4/-34)
drizzled/field.cc (+90/-56)
drizzled/field.h (+2/-1)
drizzled/field/blob.cc (+13/-19)
drizzled/field/blob.h (+36/-14)
drizzled/field/date.h (+21/-10)
drizzled/field/datetime.h (+21/-11)
drizzled/field/decimal.cc (+21/-8)
drizzled/field/decimal.h (+12/-5)
drizzled/field/enum.h (+13/-6)
drizzled/field/null.h (+68/-23)
drizzled/field/str.cc (+9/-5)
drizzled/field/str.h (+5/-3)
drizzled/field/timestamp.cc (+16/-11)
drizzled/field/timestamp.h (+10/-5)
drizzled/field/varstring.cc (+15/-9)
drizzled/field/varstring.h (+12/-7)
drizzled/function/func.cc (+7/-5)
drizzled/item.cc (+14/-6)
drizzled/item/insert_value.cc (+1/-2)
drizzled/item/sum.cc (+1/-2)
drizzled/item/type_holder.cc (+7/-3)
drizzled/key.cc (+1/-2)
drizzled/message/table.proto (+0/-2)
drizzled/sql_table.cc (+48/-71)
drizzled/statement/alter_table.cc (+1/-2)
drizzled/stored_key.h (+8/-3)
drizzled/table.cc (+218/-191)
drizzled/table_proto_write.cc (+32/-4)
plugin/innobase/handler/handler0alter.cc (+1/-2)
To merge this branch: bzr merge lp:~stewart/drizzle/jay-and-stewart-remove-pack_flag
Reviewer Review Type Date Requested Status
Jay Pipes Pending
Brian Aker Pending
Monty Taylor Pending
Review via email: mp+12511@code.launchpad.net

This proposal supersedes a proposal from 2009-09-24.

To post a comment you must log in.
Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

Jay's pack_flag removal branch, plus fixes for Solaris Sparc (works on bitters) and complete removal of pack_flag from the table proto (it's still a bit inside the create table path though, it just doesn't exist in the table proto any more).

Jay's work was previously okayed except for failing on solaris sparc (which is fixed in this branch)

My stuff is new here.

Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

Nice work, Stewart. I looked over your commits and everything looked fine. Would be nice to also remove the remaining macros/#defines from definitions, but this is excellent progress.

review: Approve
Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

On Thu, Sep 24, 2009 at 07:10:01PM -0000, Jay Pipes wrote:
> Review: Approve
> Nice work, Stewart. I looked over your commits and everything looked
> fine. Would be nice to also remove the remaining macros/#defines from
> definitions, but this is excellent progress.

It's still used in some strange way in the create table path to produce
key_type (which is still stored in the table proto), so just ripping
those bits out leads to a not quite working server :(

next tree :) (as key_type must also go... or at least be converted to
something sane).

--
Stewart Smith

Revision history for this message
Brian Aker (brianaker) wrote : Posted in a previous version of this proposal

Hi!

A few things:
make_field you pass "decimals" as an int. This is later used as a uint8_t though. Overflow for double/new_decimal.

new_decimal should just become "decimal".

For new variables, use a sized variable not just "int".

I'm not sure what to do about the format changes. They are good... but there are a lot of them that have nothing to do with the patch itself. It is good to fix these things, but there are a lot of them have nothing to do with the patch (which makes the patch very hard to follow). It would be nice if large scale changes in style were done as a patch, and core changes were done in another. Little bits here and there... but there are a lot of style changes going on that are not touching direct code. I'm not sure what to do about that for this patch.

Cheers,
   -Brian

review: Needs Fixing
Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

> I'm not sure what to do about the format changes. They are good... but there
> are a lot of them that have nothing to do with the patch itself. It is good to
> fix these things, but there are a lot of them have nothing to do with the
> patch (which makes the patch very hard to follow). It would be nice if large
> scale changes in style were done as a patch, and core changes were done in
> another. Little bits here and there... but there are a lot of style changes
> going on that are not touching direct code. I'm not sure what to do about that
> for this patch.

OK, point taken, and these style changes I will take responsibility for. For this patch, can you make an exception and try to follow along with the patch? I'd hate to have to redo this whole patch in order to pull out style changes. I will certainly take this to heart on future patches, though, rest assured.

This patch was, originally, smaller patches, and it wouldn't have been as big, but the original patch had the issue with the sum_distinct test case only on bitters, and it got bigger after that too...

In short, can we fix the issues with sized variables and new_decimal, and push this into the tree?

Revision history for this message
Brian Aker (brianaker) wrote : Posted in a previous version of this proposal

Yes, we can skip the style for the moment.

I am still spending a bit more time on this. Looking at Decimal I see this:

    message NumericFieldOptions {
      optional bool is_autoincrement = 1 [default = false];
      optional int32 length = 2;
      optional int32 scale = 3;
      optional int32 precision = 4;
    }

Can any of those value be anything put positive? Are those size appropriate for those fields?

Revision history for this message
Brian Aker (brianaker) wrote : Posted in a previous version of this proposal

And while I am at it:

    message StringFieldOptions {
      optional bool is_fixed_width = 1 [default = false];
      optional int32 length = 2;
      optional uint32 collation_id = 3;
      optional string collation = 4;
    }

length is limited to signed?

    message SetFieldOptions {
      required int32 count_elements = 1;
      optional uint32 collation_id = 2;
      optional string collation = 3;
      repeated bytes field_value = 4;
    }
Is this now deprecated?

Revision history for this message
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

> And while I am at it:
>
> message StringFieldOptions {
> optional bool is_fixed_width = 1 [default = false];
> optional int32 length = 2;
> optional uint32 collation_id = 3;
> optional string collation = 4;
> }
>
> length is limited to signed?

unsigned may be an idea.

I also don't see any real reason why it should only be 32bits.

>
> message SetFieldOptions {
> required int32 count_elements = 1;
> optional uint32 collation_id = 2;
> optional string collation = 3;
> repeated bytes field_value = 4;
> }
> Is this now deprecated?

Yes. This is only the first in many-to-come table proto cleanup patches. The pack_flag part was one of the more critical though (makes it really hard to generate a table proto if you have to work otu what a pack_flag is meant to be)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/common.h'
2--- drizzled/common.h 2009-08-04 06:52:55 +0000
3+++ drizzled/common.h 2009-09-28 07:40:31 +0000
4@@ -166,7 +166,6 @@
5 #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
6 #define BLOB_FLAG 16 /* Field is a blob */
7 #define UNSIGNED_FLAG 32 /* Field is unsigned */
8-#define DECIMAL_FLAG 64 /* Field is zerofill */
9 #define BINARY_FLAG 128 /* Field is binary */
10
11 /* The following are only sent to new clients */
12
13=== modified file 'drizzled/create_field.cc'
14--- drizzled/create_field.cc 2009-08-31 23:50:37 +0000
15+++ drizzled/create_field.cc 2009-09-28 07:40:31 +0000
16@@ -150,8 +150,9 @@
17 Init for a tmp table field. To be extended if need be.
18 */
19 void CreateField::init_for_tmp_table(enum_field_types sql_type_arg,
20- uint32_t length_arg, uint32_t decimals_arg,
21- bool maybe_null, bool is_unsigned)
22+ uint32_t length_arg,
23+ uint32_t decimals_arg,
24+ bool maybe_null)
25 {
26 field_name= "";
27 sql_type= sql_type_arg;
28@@ -159,10 +160,13 @@
29 unireg_check= Field::NONE;
30 interval= 0;
31 charset= &my_charset_bin;
32- pack_flag= (FIELDFLAG_NUMBER |
33- ((decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) |
34- (maybe_null ? FIELDFLAG_MAYBE_NULL : 0) |
35- (is_unsigned ? 0 : FIELDFLAG_DECIMAL));
36+ decimals= decimals_arg & FIELDFLAG_MAX_DEC;
37+ pack_flag= 0;
38+
39+ if (! maybe_null)
40+ flags= NOT_NULL_FLAG;
41+ else
42+ flags= 0;
43 }
44
45 bool CreateField::init(Session *,
46
47=== modified file 'drizzled/create_field.h'
48--- drizzled/create_field.h 2009-08-05 08:52:52 +0000
49+++ drizzled/create_field.h 2009-09-28 07:40:31 +0000
50@@ -82,8 +82,7 @@
51 void init_for_tmp_table(enum_field_types sql_type_arg,
52 uint32_t max_length,
53 uint32_t decimals,
54- bool maybe_null,
55- bool is_unsigned);
56+ bool maybe_null);
57
58 /**
59 Initialize field definition for create.
60
61=== modified file 'drizzled/definitions.h'
62--- drizzled/definitions.h 2009-08-22 02:06:02 +0000
63+++ drizzled/definitions.h 2009-09-28 07:40:31 +0000
64@@ -23,8 +23,8 @@
65 * Mostly constants and some macros/functions used by the server
66 */
67
68-#ifndef DRIZZLE_SERVER_DEFINITIONS_H
69-#define DRIZZLE_SERVER_DEFINITIONS_H
70+#ifndef DRIZZLED_DEFINITIONS_H
71+#define DRIZZLED_DEFINITIONS_H
72
73 #include <drizzled/enum.h>
74
75@@ -578,42 +578,12 @@
76 * The following are for the interface with the .frm file
77 */
78
79-#define FIELDFLAG_DECIMAL 1
80-#define FIELDFLAG_BINARY 1 // Shares same flag
81-#define FIELDFLAG_NUMBER 2
82-#define FIELDFLAG_DECIMAL_POSITION 4
83-#define FIELDFLAG_PACK 120 // Bits used for packing
84-#define FIELDFLAG_INTERVAL 256 // mangled with decimals!
85-#define FIELDFLAG_BLOB 1024 // mangled with decimals!
86-
87-#define FIELDFLAG_NO_DEFAULT 16384 /* sql */
88-#define FIELDFLAG_SUM ((uint32_t) 32768)// predit: +#fieldflag
89-#define FIELDFLAG_MAYBE_NULL ((uint32_t) 32768)// sql
90-#define FIELDFLAG_HEX_ESCAPE ((uint32_t) 0x10000)
91 #define FIELDFLAG_PACK_SHIFT 3
92-#define FIELDFLAG_DEC_SHIFT 8
93 #define FIELDFLAG_MAX_DEC 31
94
95 #define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
96
97-#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
98-#define f_is_num(x) ((x) & FIELDFLAG_NUMBER)
99-#define f_is_decimal_precision(x) ((x) & FIELDFLAG_DECIMAL_POSITION)
100-#define f_is_packed(x) ((x) & FIELDFLAG_PACK)
101 #define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
102-#define f_decimals(x) ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
103- FIELDFLAG_MAX_DEC))
104-#define f_is_alpha(x) (!f_is_num(x))
105-#define f_is_binary(x) ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
106-#define f_is_enum(x) (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
107- FIELDFLAG_INTERVAL)
108-#define f_is_blob(x) (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
109- FIELDFLAG_BLOB)
110-#define f_is_equ(x) ((x) & (1+2+FIELDFLAG_PACK+31*256))
111 #define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
112-#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
113-#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
114-#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
115-
116-#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
117-
118+
119+#endif /* DRIZZLED_DEFINITIONS_H */
120
121=== modified file 'drizzled/field.cc'
122--- drizzled/field.cc 2009-07-29 23:25:20 +0000
123+++ drizzled/field.cc 2009-09-28 07:40:31 +0000
124@@ -1019,19 +1019,20 @@
125 MEM_ROOT *root,
126 unsigned char *ptr,
127 uint32_t field_length,
128+ bool is_nullable,
129 unsigned char *null_pos,
130 unsigned char null_bit,
131- uint32_t pack_flag,
132+ uint8_t decimals,
133 enum_field_types field_type,
134 const CHARSET_INFO * field_charset,
135 Field::utype unireg_check,
136 TYPELIB *interval,
137 const char *field_name)
138 {
139- if(!root)
140+ if(! root)
141 root= current_mem_root();
142
143- if (!f_maybe_null(pack_flag))
144+ if (! is_nullable)
145 {
146 null_pos=0;
147 null_bit=0;
148@@ -1041,7 +1042,8 @@
149 null_bit= ((unsigned char) 1) << null_bit;
150 }
151
152- switch (field_type) {
153+ switch (field_type)
154+ {
155 case DRIZZLE_TYPE_DATE:
156 case DRIZZLE_TYPE_DATETIME:
157 case DRIZZLE_TYPE_TIMESTAMP:
158@@ -1049,79 +1051,111 @@
159 default: break;
160 }
161
162- if (f_is_alpha(pack_flag))
163+ if (field_type == DRIZZLE_TYPE_VARCHAR ||
164+ field_type == DRIZZLE_TYPE_BLOB ||
165+ field_type == DRIZZLE_TYPE_ENUM)
166 {
167- if (!f_is_packed(pack_flag))
168+ if (field_type == DRIZZLE_TYPE_VARCHAR)
169+ return new (root) Field_varstring(ptr,field_length,
170+ HA_VARCHAR_PACKLENGTH(field_length),
171+ null_pos,null_bit,
172+ field_name,
173+ share,
174+ field_charset);
175+
176+ if (field_type == DRIZZLE_TYPE_BLOB)
177 {
178- if (field_type == DRIZZLE_TYPE_VARCHAR)
179- return new (root) Field_varstring(ptr,field_length,
180- HA_VARCHAR_PACKLENGTH(field_length),
181- null_pos,null_bit,
182- unireg_check, field_name,
183+ return new (root) Field_blob(ptr,
184+ null_pos,
185+ null_bit,
186+ field_name,
187 share,
188+ calc_pack_length(DRIZZLE_TYPE_LONG, 0),
189 field_charset);
190- return 0; // Error
191 }
192
193- uint32_t pack_length=calc_pack_length((enum_field_types)
194- f_packtype(pack_flag),
195- field_length);
196-
197- if (f_is_blob(pack_flag))
198- return new (root) Field_blob(ptr,null_pos,null_bit,
199- unireg_check, field_name, share,
200- pack_length, field_charset);
201 if (interval)
202 {
203- if (f_is_enum(pack_flag))
204- {
205- return new (root) Field_enum(ptr,field_length,null_pos,null_bit,
206- unireg_check, field_name,
207- get_enum_pack_length(interval->count),
208- interval, field_charset);
209- }
210+ return new (root) Field_enum(ptr,
211+ field_length,
212+ null_pos,
213+ null_bit,
214+ field_name,
215+ get_enum_pack_length(interval->count),
216+ interval,
217+ field_charset);
218 }
219 }
220
221- switch (field_type) {
222+ switch (field_type)
223+ {
224 case DRIZZLE_TYPE_NEWDECIMAL:
225- return new (root) Field_new_decimal(ptr,field_length,null_pos,null_bit,
226- unireg_check, field_name,
227- f_decimals(pack_flag),
228- f_is_decimal_precision(pack_flag) != 0,
229- f_is_dec(pack_flag) == 0);
230+ return new (root) Field_new_decimal(ptr,
231+ field_length,
232+ null_pos,
233+ null_bit,
234+ unireg_check,
235+ field_name,
236+ decimals,
237+ false,
238+ false /* is_unsigned */);
239 case DRIZZLE_TYPE_DOUBLE:
240- return new (root) Field_double(ptr,field_length,null_pos,null_bit,
241- unireg_check, field_name,
242- f_decimals(pack_flag),
243- false,
244- f_is_dec(pack_flag)== 0);
245+ return new (root) Field_double(ptr,
246+ field_length,
247+ null_pos,
248+ null_bit,
249+ unireg_check,
250+ field_name,
251+ decimals,
252+ false,
253+ false /* is_unsigned */);
254 case DRIZZLE_TYPE_TINY:
255 assert(0);
256 case DRIZZLE_TYPE_LONG:
257- return new (root) Field_long(ptr,field_length,null_pos,null_bit,
258- unireg_check, field_name,
259- false,
260- f_is_dec(pack_flag) == 0);
261+ return new (root) Field_long(ptr,
262+ field_length,
263+ null_pos,
264+ null_bit,
265+ unireg_check,
266+ field_name,
267+ false,
268+ false /* is_unsigned */);
269 case DRIZZLE_TYPE_LONGLONG:
270- return new (root) Field_int64_t(ptr,field_length,null_pos,null_bit,
271- unireg_check, field_name,
272- false,
273- f_is_dec(pack_flag) == 0);
274+ return new (root) Field_int64_t(ptr,
275+ field_length,
276+ null_pos,
277+ null_bit,
278+ unireg_check,
279+ field_name,
280+ false,
281+ false /* is_unsigned */);
282 case DRIZZLE_TYPE_TIMESTAMP:
283- return new (root) Field_timestamp(ptr,field_length, null_pos, null_bit,
284- unireg_check, field_name, share,
285- field_charset);
286+ return new (root) Field_timestamp(ptr,
287+ field_length,
288+ null_pos,
289+ null_bit,
290+ unireg_check,
291+ field_name,
292+ share,
293+ field_charset);
294 case DRIZZLE_TYPE_DATE:
295- return new (root) Field_date(ptr,null_pos,null_bit,
296- unireg_check, field_name, field_charset);
297+ return new (root) Field_date(ptr,
298+ null_pos,
299+ null_bit,
300+ field_name,
301+ field_charset);
302 case DRIZZLE_TYPE_DATETIME:
303- return new (root) Field_datetime(ptr,null_pos,null_bit,
304- unireg_check, field_name, field_charset);
305+ return new (root) Field_datetime(ptr,
306+ null_pos,
307+ null_bit,
308+ field_name,
309+ field_charset);
310 case DRIZZLE_TYPE_NULL:
311- return new (root) Field_null(ptr, field_length, unireg_check, field_name,
312- field_charset);
313- default: // Impossible (Wrong version)
314+ return new (root) Field_null(ptr,
315+ field_length,
316+ field_name,
317+ field_charset);
318+ default: // Impossible (Wrong version)
319 break;
320 }
321 return 0;
322
323=== modified file 'drizzled/field.h'
324--- drizzled/field.h 2009-08-05 08:52:52 +0000
325+++ drizzled/field.h 2009-09-28 07:40:31 +0000
326@@ -833,9 +833,10 @@
327 MEM_ROOT *root,
328 unsigned char *ptr,
329 uint32_t field_length,
330+ bool is_nullable,
331 unsigned char *null_pos,
332 unsigned char null_bit,
333- uint32_t pack_flag,
334+ uint8_t decimals,
335 enum_field_types field_type,
336 const CHARSET_INFO * cs,
337 Field::utype unireg_check,
338
339=== modified file 'drizzled/field/blob.cc'
340--- drizzled/field/blob.cc 2009-07-11 08:51:36 +0000
341+++ drizzled/field/blob.cc 2009-09-28 07:40:31 +0000
342@@ -42,13 +42,19 @@
343 ** packlength slot and may be from 1-4.
344 ****************************************************************************/
345
346-Field_blob::Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg,
347- enum utype unireg_check_arg, const char *field_name_arg,
348- TableShare *share, uint32_t blob_pack_length,
349- const CHARSET_INFO * const cs)
350- :Field_str(ptr_arg, blob_pack_length_to_max_length(blob_pack_length),
351- null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg,
352- cs),
353+Field_blob::Field_blob(unsigned char *ptr_arg,
354+ unsigned char *null_ptr_arg,
355+ unsigned char null_bit_arg,
356+ const char *field_name_arg,
357+ TableShare *share,
358+ uint32_t blob_pack_length,
359+ const CHARSET_INFO * const cs)
360+ :Field_str(ptr_arg,
361+ blob_pack_length_to_max_length(blob_pack_length),
362+ null_ptr_arg,
363+ null_bit_arg,
364+ field_name_arg,
365+ cs),
366 packlength(blob_pack_length)
367 {
368 flags|= BLOB_FLAG;
369@@ -56,7 +62,6 @@
370 /* TODO: why do not fill table->s->blob_field array here? */
371 }
372
373-
374 void Field_blob::store_length(unsigned char *i_ptr,
375 uint32_t i_packlength,
376 uint32_t i_number,
377@@ -226,17 +231,6 @@
378 if (value.alloc(new_length))
379 goto oom_error;
380
381-
382- if (f_is_hex_escape(flags))
383- {
384- copy_length= my_copy_with_hex_escaping(field_charset,
385- (char*) value.ptr(), new_length,
386- from, length);
387- Field_blob::store_length(copy_length);
388- tmp= value.ptr();
389- memmove(ptr + packlength, &tmp, sizeof(char*));
390- return 0;
391- }
392 /*
393 "length" is OK as "nchars" argument to well_formed_copy_nchars as this
394 is never used to limit the length of the data. The cut of long data
395
396=== modified file 'drizzled/field/blob.h'
397--- drizzled/field/blob.h 2009-06-13 21:21:13 +0000
398+++ drizzled/field/blob.h 2009-09-28 07:40:31 +0000
399@@ -41,25 +41,41 @@
400 using Field::val_int;
401 using Field::val_str;
402
403-
404- Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg,
405- enum utype unireg_check_arg, const char *field_name_arg,
406- TableShare *share, uint32_t blob_pack_length, const CHARSET_INFO * const cs);
407- Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
408+ Field_blob(unsigned char *ptr_arg,
409+ unsigned char *null_ptr_arg,
410+ unsigned char null_bit_arg,
411+ const char *field_name_arg,
412+ TableShare *share,
413+ uint32_t blob_pack_length,
414+ const CHARSET_INFO * const cs);
415+ Field_blob(uint32_t len_arg,
416+ bool maybe_null_arg,
417+ const char *field_name_arg,
418 const CHARSET_INFO * const cs)
419- :Field_str((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
420- NONE, field_name_arg, cs),
421+ :Field_str((unsigned char*) NULL,
422+ len_arg,
423+ maybe_null_arg ? (unsigned char *) "": 0,
424+ 0,
425+ field_name_arg,
426+ cs),
427 packlength(4)
428 {
429 flags|= BLOB_FLAG;
430 }
431- Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
432- const CHARSET_INFO * const cs, bool set_packlength)
433- :Field_str((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
434- NONE, field_name_arg, cs)
435+ Field_blob(uint32_t len_arg,
436+ bool maybe_null_arg,
437+ const char *field_name_arg,
438+ const CHARSET_INFO * const cs,
439+ bool set_packlength)
440+ :Field_str((unsigned char*) NULL,
441+ len_arg,
442+ maybe_null_arg ? (unsigned char*) "": 0,
443+ 0,
444+ field_name_arg,
445+ cs),
446+ packlength(4)
447 {
448 flags|= BLOB_FLAG;
449- packlength= 4;
450 if (set_packlength)
451 {
452 uint32_t l_char_length= len_arg/cs->mbmaxlen;
453@@ -69,8 +85,14 @@
454 }
455 }
456 Field_blob(uint32_t packlength_arg)
457- :Field_str((unsigned char*) 0, 0, (unsigned char*) "", 0, NONE, "temp", system_charset_info),
458- packlength(packlength_arg) {}
459+ :Field_str((unsigned char*) 0,
460+ 0,
461+ (unsigned char*) "",
462+ 0,
463+ "temp",
464+ system_charset_info),
465+ packlength(packlength_arg)
466+ {}
467 enum_field_types type() const { return DRIZZLE_TYPE_BLOB;}
468 enum ha_base_keytype key_type() const
469 { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
470
471=== modified file 'drizzled/field/date.h'
472--- drizzled/field/date.h 2009-02-17 14:41:01 +0000
473+++ drizzled/field/date.h 2009-09-28 07:40:31 +0000
474@@ -31,17 +31,28 @@
475 using Field::val_str;
476 using Field::cmp;
477
478- Field_date(unsigned char *ptr_arg, unsigned char *null_ptr_arg,
479+ Field_date(unsigned char *ptr_arg,
480+ unsigned char *null_ptr_arg,
481 unsigned char null_bit_arg,
482- enum utype unireg_check_arg, const char *field_name_arg,
483- const CHARSET_INFO * const cs)
484- :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
485- unireg_check_arg, field_name_arg, cs)
486- {}
487- Field_date(bool maybe_null_arg, const char *field_name_arg,
488- const CHARSET_INFO * const cs)
489- :Field_str((unsigned char*) 0,10, maybe_null_arg ? (unsigned char*) "": 0,0,
490- NONE, field_name_arg, cs) {}
491+ const char *field_name_arg,
492+ const CHARSET_INFO * const cs)
493+ :Field_str(ptr_arg,
494+ 10,
495+ null_ptr_arg,
496+ null_bit_arg,
497+ field_name_arg,
498+ cs)
499+ {}
500+ Field_date(bool maybe_null_arg,
501+ const char *field_name_arg,
502+ const CHARSET_INFO * const cs)
503+ :Field_str((unsigned char*) 0,
504+ 10,
505+ maybe_null_arg ? (unsigned char*) "": 0,
506+ 0,
507+ field_name_arg,
508+ cs)
509+ {}
510 enum_field_types type() const { return DRIZZLE_TYPE_DATE;}
511 enum_field_types real_type() const { return DRIZZLE_TYPE_DATE; }
512 enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
513
514=== modified file 'drizzled/field/datetime.h'
515--- drizzled/field/datetime.h 2009-02-20 08:45:29 +0000
516+++ drizzled/field/datetime.h 2009-09-28 07:40:31 +0000
517@@ -31,17 +31,28 @@
518 using Field::val_str;
519 using Field::cmp;
520
521- Field_datetime(unsigned char *ptr_arg, unsigned char *null_ptr_arg,
522+ Field_datetime(unsigned char *ptr_arg,
523+ unsigned char *null_ptr_arg,
524 unsigned char null_bit_arg,
525- enum utype unireg_check_arg, const char *field_name_arg,
526- const CHARSET_INFO * const cs)
527- :Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
528- unireg_check_arg, field_name_arg, cs)
529- {}
530- Field_datetime(bool maybe_null_arg, const char *field_name_arg,
531- const CHARSET_INFO * const cs)
532- :Field_str((unsigned char*) 0,19, maybe_null_arg ? (unsigned char*) "": 0,0,
533- NONE, field_name_arg, cs) {}
534+ const char *field_name_arg,
535+ const CHARSET_INFO * const cs)
536+ :Field_str(ptr_arg,
537+ 19,
538+ null_ptr_arg,
539+ null_bit_arg,
540+ field_name_arg,
541+ cs)
542+ {}
543+ Field_datetime(bool maybe_null_arg,
544+ const char *field_name_arg,
545+ const CHARSET_INFO * const cs)
546+ :Field_str((unsigned char*) 0,
547+ 19,
548+ maybe_null_arg ? (unsigned char*) "": 0,
549+ 0,
550+ field_name_arg,
551+ cs)
552+ {}
553 enum_field_types type() const { return DRIZZLE_TYPE_DATETIME;}
554 enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
555 enum Item_result cmp_type () const { return INT_RESULT; }
556@@ -69,4 +80,3 @@
557 };
558
559 #endif
560-
561
562=== modified file 'drizzled/field/decimal.cc'
563--- drizzled/field/decimal.cc 2009-07-10 00:01:50 +0000
564+++ drizzled/field/decimal.cc 2009-09-28 07:40:31 +0000
565@@ -32,14 +32,22 @@
566 ****************************************************************************/
567
568 Field_new_decimal::Field_new_decimal(unsigned char *ptr_arg,
569- uint32_t len_arg, unsigned char *null_ptr_arg,
570+ uint32_t len_arg,
571+ unsigned char *null_ptr_arg,
572 unsigned char null_bit_arg,
573 enum utype unireg_check_arg,
574 const char *field_name_arg,
575- uint8_t dec_arg,bool zero_arg,
576+ uint8_t dec_arg,
577+ bool zero_arg,
578 bool unsigned_arg)
579- :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
580- unireg_check_arg, field_name_arg, dec_arg, zero_arg, unsigned_arg)
581+ :Field_num(ptr_arg,
582+ len_arg,
583+ null_ptr_arg,
584+ null_bit_arg,
585+ unireg_check_arg,
586+ field_name_arg,
587+ dec_arg, zero_arg,
588+ unsigned_arg)
589 {
590 precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
591 set_if_smaller(precision, (uint32_t)DECIMAL_MAX_PRECISION);
592@@ -48,15 +56,20 @@
593 bin_size= my_decimal_get_binary_size(precision, dec);
594 }
595
596-
597 Field_new_decimal::Field_new_decimal(uint32_t len_arg,
598 bool maybe_null_arg,
599 const char *name,
600 uint8_t dec_arg,
601 bool unsigned_arg)
602- :Field_num((unsigned char*) 0, len_arg,
603- maybe_null_arg ? (unsigned char*) "": 0, 0,
604- NONE, name, dec_arg, 0, unsigned_arg)
605+ :Field_num((unsigned char*) 0,
606+ len_arg,
607+ maybe_null_arg ? (unsigned char*) "": 0,
608+ 0,
609+ NONE,
610+ name,
611+ dec_arg,
612+ 0,
613+ unsigned_arg)
614 {
615 precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
616 set_if_smaller(precision, (uint32_t)DECIMAL_MAX_PRECISION);
617
618=== modified file 'drizzled/field/decimal.h'
619--- drizzled/field/decimal.h 2009-06-05 22:51:06 +0000
620+++ drizzled/field/decimal.h 2009-09-28 07:40:31 +0000
621@@ -44,12 +44,19 @@
622 So for example we need to count length from precision handling
623 CREATE TABLE ( DECIMAL(x,y))
624 */
625- Field_new_decimal(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
626+ Field_new_decimal(unsigned char *ptr_arg,
627+ uint32_t len_arg,
628+ unsigned char *null_ptr_arg,
629 unsigned char null_bit_arg,
630- enum utype unireg_check_arg, const char *field_name_arg,
631- uint8_t dec_arg, bool zero_arg, bool unsigned_arg);
632- Field_new_decimal(uint32_t len_arg, bool maybe_null_arg,
633- const char *field_name_arg, uint8_t dec_arg,
634+ enum utype unireg_check_arg,
635+ const char *field_name_arg,
636+ uint8_t dec_arg,
637+ bool zero_arg,
638+ bool unsigned_arg);
639+ Field_new_decimal(uint32_t len_arg,
640+ bool maybe_null_arg,
641+ const char *field_name_arg,
642+ uint8_t dec_arg,
643 bool unsigned_arg);
644 enum_field_types type() const { return DRIZZLE_TYPE_NEWDECIMAL;}
645 enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
646
647=== modified file 'drizzled/field/enum.h'
648--- drizzled/field/enum.h 2009-03-16 15:20:27 +0000
649+++ drizzled/field/enum.h 2009-09-28 07:40:31 +0000
650@@ -36,17 +36,24 @@
651
652 /** Internal storage for the string values of the ENUM */
653 TYPELIB *typelib;
654- Field_enum(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
655+ Field_enum(unsigned char *ptr_arg,
656+ uint32_t len_arg,
657+ unsigned char *null_ptr_arg,
658 unsigned char null_bit_arg,
659- enum utype unireg_check_arg, const char *field_name_arg,
660+ const char *field_name_arg,
661 uint32_t packlength_arg,
662 TYPELIB *typelib_arg,
663 const CHARSET_INFO * const charset_arg)
664- :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
665- unireg_check_arg, field_name_arg, charset_arg),
666- packlength(packlength_arg),typelib(typelib_arg)
667+ :Field_str(ptr_arg,
668+ len_arg,
669+ null_ptr_arg,
670+ null_bit_arg,
671+ field_name_arg,
672+ charset_arg),
673+ packlength(packlength_arg),
674+ typelib(typelib_arg)
675 {
676- flags|=ENUM_FLAG;
677+ flags|= ENUM_FLAG;
678 }
679 Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
680 enum ha_base_keytype key_type() const;
681
682=== modified file 'drizzled/field/null.h'
683--- drizzled/field/null.h 2009-02-20 08:45:29 +0000
684+++ drizzled/field/null.h 2009-09-28 07:40:31 +0000
685@@ -27,7 +27,8 @@
686 * Everything saved in this will disappear. It will always return NULL
687 */
688
689-class Field_null :public Field_str {
690+class Field_null :public Field_str
691+{
692 static unsigned char null[1];
693 public:
694
695@@ -36,37 +37,81 @@
696 using Field::cmp;
697 using Field::val_int;
698
699- Field_null(unsigned char *ptr_arg, uint32_t len_arg,
700- enum utype unireg_check_arg, const char *field_name_arg,
701- const CHARSET_INFO * const cs)
702- :Field_str(ptr_arg, len_arg, null, 1,
703- unireg_check_arg, field_name_arg, cs)
704- {}
705- enum_field_types type() const { return DRIZZLE_TYPE_NULL;}
706+ Field_null(unsigned char *ptr_arg,
707+ uint32_t len_arg,
708+ const char *field_name_arg,
709+ const CHARSET_INFO * const cs)
710+ :Field_str(ptr_arg,
711+ len_arg,
712+ null,
713+ 1,
714+ field_name_arg,
715+ cs)
716+ {}
717+ enum_field_types type() const
718+ {
719+ return DRIZZLE_TYPE_NULL;
720+ }
721 int store(const char *, uint32_t, const CHARSET_INFO * const)
722- { null[0]=1; return 0; }
723+ {
724+ null[0]= 1;
725+ return 0;
726+ }
727 int store(double)
728- { null[0]=1; return 0; }
729+ {
730+ null[0]= 1;
731+ return 0;
732+ }
733 int store(int64_t, bool)
734- { null[0]=1; return 0; }
735+ {
736+ null[0]= 1;
737+ return 0;
738+ }
739 int store_decimal(const my_decimal *)
740- { null[0]=1; return 0; }
741+ {
742+ null[0]= 1;
743+ return 0;
744+ }
745 int reset(void)
746- { return 0; }
747+ {
748+ return 0;
749+ }
750 double val_real(void)
751- { return 0.0;}
752+ {
753+ return 0.0;
754+ }
755 int64_t val_int(void)
756- { return 0;}
757- my_decimal *val_decimal(my_decimal *) { return 0; }
758+ {
759+ return 0;
760+ }
761+ my_decimal *val_decimal(my_decimal *)
762+ {
763+ return 0;
764+ }
765 String *val_str(String *, String *value2)
766- { value2->length(0); return value2;}
767- int cmp(const unsigned char *, const unsigned char *) { return 0;}
768- void sort_string(unsigned char *, uint32_t) {}
769- uint32_t pack_length() const { return 0; }
770+ {
771+ value2->length(0);
772+ return value2;
773+ }
774+ int cmp(const unsigned char *, const unsigned char *)
775+ {
776+ return 0;
777+ }
778+ void sort_string(unsigned char *, uint32_t)
779+ {}
780+ uint32_t pack_length() const
781+ {
782+ return 0;
783+ }
784 void sql_type(String &str) const;
785- uint32_t size_of() const { return sizeof(*this); }
786- uint32_t max_display_length() { return 4; }
787+ uint32_t size_of() const
788+ {
789+ return sizeof(*this);
790+ }
791+ uint32_t max_display_length()
792+ {
793+ return 4;
794+ }
795 };
796
797 #endif
798-
799
800=== modified file 'drizzled/field/str.cc'
801--- drizzled/field/str.cc 2009-07-10 00:01:50 +0000
802+++ drizzled/field/str.cc 2009-09-28 07:40:31 +0000
803@@ -26,17 +26,21 @@
804 #include <drizzled/session.h>
805
806
807-Field_str::Field_str(unsigned char *ptr_arg,uint32_t len_arg,
808+Field_str::Field_str(unsigned char *ptr_arg,
809+ uint32_t len_arg,
810 unsigned char *null_ptr_arg,
811- unsigned char null_bit_arg, utype unireg_check_arg,
812+ unsigned char null_bit_arg,
813 const char *field_name_arg,
814 const CHARSET_INFO * const charset_arg)
815- :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
816- unireg_check_arg, field_name_arg)
817+ :Field(ptr_arg, len_arg,
818+ null_ptr_arg,
819+ null_bit_arg,
820+ Field::NONE,
821+ field_name_arg)
822 {
823 field_charset= charset_arg;
824 if (charset_arg->state & MY_CS_BINSORT)
825- flags|=BINARY_FLAG;
826+ flags|= BINARY_FLAG;
827 field_derivation= DERIVATION_IMPLICIT;
828 }
829
830
831=== modified file 'drizzled/field/str.h'
832--- drizzled/field/str.h 2009-06-05 22:51:06 +0000
833+++ drizzled/field/str.h 2009-09-28 07:40:31 +0000
834@@ -33,10 +33,12 @@
835 enum Derivation field_derivation;
836 int report_if_important_data(const char *ptr, const char *end);
837 public:
838- Field_str(unsigned char *ptr_arg,uint32_t len_arg,
839+ Field_str(unsigned char *ptr_arg,
840+ uint32_t len_arg,
841 unsigned char *null_ptr_arg,
842- unsigned char null_bit_arg, utype unireg_check_arg,
843- const char *field_name_arg, const CHARSET_INFO * const charset);
844+ unsigned char null_bit_arg,
845+ const char *field_name_arg,
846+ const CHARSET_INFO * const charset);
847 Item_result result_type () const { return STRING_RESULT; }
848 uint32_t decimals() const { return NOT_FIXED_DEC; }
849
850
851=== modified file 'drizzled/field/timestamp.cc'
852--- drizzled/field/timestamp.cc 2009-07-10 00:01:50 +0000
853+++ drizzled/field/timestamp.cc 2009-09-28 07:40:31 +0000
854@@ -28,7 +28,6 @@
855
856 #include "drizzled/temporal.h"
857
858-
859 /**
860 TIMESTAMP type holds datetime values in range from 1970-01-01 00:00:01 UTC to
861 2038-01-01 00:00:00 UTC stored as number of seconds since Unix
862@@ -73,20 +72,24 @@
863 exception is different behavior of old/new timestamps during ALTER TABLE.
864 */
865 Field_timestamp::Field_timestamp(unsigned char *ptr_arg,
866- uint32_t ,
867- unsigned char *null_ptr_arg, unsigned char null_bit_arg,
868+ uint32_t,
869+ unsigned char *null_ptr_arg,
870+ unsigned char null_bit_arg,
871 enum utype unireg_check_arg,
872 const char *field_name_arg,
873 TableShare *share,
874 const CHARSET_INFO * const cs)
875 :Field_str(ptr_arg,
876 drizzled::DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
877- null_ptr_arg, null_bit_arg,
878- unireg_check_arg, field_name_arg, cs)
879+ null_ptr_arg,
880+ null_bit_arg,
881+ field_name_arg,
882+ cs)
883 {
884 /* For 4.0 MYD and 4.0 InnoDB compatibility */
885 flags|= UNSIGNED_FLAG;
886- if (!share->timestamp_field && unireg_check != NONE)
887+ unireg_check= unireg_check_arg;
888+ if (! share->timestamp_field && unireg_check != NONE)
889 {
890 /* This timestamp has auto-update */
891 share->timestamp_field= this;
892@@ -99,15 +102,17 @@
893 Field_timestamp::Field_timestamp(bool maybe_null_arg,
894 const char *field_name_arg,
895 const CHARSET_INFO * const cs)
896- :Field_str((unsigned char*) 0,
897+ :Field_str((unsigned char*) NULL,
898 drizzled::DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
899- maybe_null_arg ? (unsigned char*) "": 0, 0,
900- NONE, field_name_arg, cs)
901+ maybe_null_arg ? (unsigned char*) "": 0,
902+ 0,
903+ field_name_arg,
904+ cs)
905 {
906 /* For 4.0 MYD and 4.0 InnoDB compatibility */
907 flags|= UNSIGNED_FLAG;
908- if (unireg_check != TIMESTAMP_DN_FIELD)
909- flags|= ON_UPDATE_NOW_FLAG;
910+ if (unireg_check != TIMESTAMP_DN_FIELD)
911+ flags|= ON_UPDATE_NOW_FLAG;
912 }
913
914 /**
915
916=== modified file 'drizzled/field/timestamp.h'
917--- drizzled/field/timestamp.h 2009-04-28 21:46:57 +0000
918+++ drizzled/field/timestamp.h 2009-09-28 07:40:31 +0000
919@@ -33,11 +33,16 @@
920 using Field::val_str;
921 using Field::cmp;
922 using Field::store;
923- Field_timestamp(unsigned char *ptr_arg, uint32_t len_arg,
924- unsigned char *null_ptr_arg, unsigned char null_bit_arg,
925- enum utype unireg_check_arg, const char *field_name_arg,
926- TableShare *share, const CHARSET_INFO * const cs);
927- Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
928+ Field_timestamp(unsigned char *ptr_arg,
929+ uint32_t len_arg,
930+ unsigned char *null_ptr_arg,
931+ unsigned char null_bit_arg,
932+ enum utype unireg_check_arg,
933+ const char *field_name_arg,
934+ TableShare *share,
935+ const CHARSET_INFO * const cs);
936+ Field_timestamp(bool maybe_null_arg,
937+ const char *field_name_arg,
938 const CHARSET_INFO * const cs);
939 enum_field_types type() const { return DRIZZLE_TYPE_TIMESTAMP;}
940 enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
941
942=== modified file 'drizzled/field/varstring.cc'
943--- drizzled/field/varstring.cc 2009-07-10 00:01:50 +0000
944+++ drizzled/field/varstring.cc 2009-09-28 07:40:31 +0000
945@@ -47,33 +47,39 @@
946 const uint32_t Field_varstring::MAX_SIZE= UINT16_MAX;
947
948 Field_varstring::Field_varstring(unsigned char *ptr_arg,
949- uint32_t len_arg, uint32_t length_bytes_arg,
950+ uint32_t len_arg,
951+ uint32_t length_bytes_arg,
952 unsigned char *null_ptr_arg,
953 unsigned char null_bit_arg,
954- enum utype unireg_check_arg,
955 const char *field_name_arg,
956 TableShare *share,
957 const CHARSET_INFO * const cs)
958- :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
959- unireg_check_arg, field_name_arg, cs),
960+ :Field_str(ptr_arg,
961+ len_arg,
962+ null_ptr_arg,
963+ null_bit_arg,
964+ field_name_arg, cs),
965 length_bytes(length_bytes_arg)
966 {
967 share->varchar_fields++;
968 }
969
970-Field_varstring::Field_varstring(uint32_t len_arg,bool maybe_null_arg,
971+Field_varstring::Field_varstring(uint32_t len_arg,
972+ bool maybe_null_arg,
973 const char *field_name_arg,
974 TableShare *share,
975 const CHARSET_INFO * const cs)
976- :Field_str((unsigned char*) 0,len_arg,
977- maybe_null_arg ? (unsigned char*) "": 0, 0,
978- NONE, field_name_arg, cs),
979+ :Field_str((unsigned char*) 0,
980+ len_arg,
981+ maybe_null_arg ? (unsigned char*) "": 0,
982+ 0,
983+ field_name_arg,
984+ cs),
985 length_bytes(len_arg < 256 ? 1 :2)
986 {
987 share->varchar_fields++;
988 }
989
990-
991 /**
992 Save the field metadata for varstring fields.
993
994
995=== modified file 'drizzled/field/varstring.h'
996--- drizzled/field/varstring.h 2009-06-13 21:21:13 +0000
997+++ drizzled/field/varstring.h 2009-09-28 07:40:31 +0000
998@@ -41,13 +41,18 @@
999 /* Store number of bytes used to store length (1 or 2) */
1000 uint32_t length_bytes;
1001 Field_varstring(unsigned char *ptr_arg,
1002- uint32_t len_arg, uint32_t length_bytes_arg,
1003- unsigned char *null_ptr_arg, unsigned char null_bit_arg,
1004- enum utype unireg_check_arg, const char *field_name_arg,
1005- TableShare *share, const CHARSET_INFO * const cs);
1006- Field_varstring(uint32_t len_arg,bool maybe_null_arg,
1007- const char *field_name_arg,
1008- TableShare *share, const CHARSET_INFO * const cs);
1009+ uint32_t len_arg,
1010+ uint32_t length_bytes_arg,
1011+ unsigned char *null_ptr_arg,
1012+ unsigned char null_bit_arg,
1013+ const char *field_name_arg,
1014+ TableShare *share,
1015+ const CHARSET_INFO * const cs);
1016+ Field_varstring(uint32_t len_arg,
1017+ bool maybe_null_arg,
1018+ const char *field_name_arg,
1019+ TableShare *share,
1020+ const CHARSET_INFO * const cs);
1021
1022 enum_field_types type() const { return DRIZZLE_TYPE_VARCHAR; }
1023 enum ha_base_keytype key_type() const;
1024
1025=== modified file 'drizzled/function/func.cc'
1026--- drizzled/function/func.cc 2009-08-31 23:50:37 +0000
1027+++ drizzled/function/func.cc 2009-09-28 07:40:31 +0000
1028@@ -461,11 +461,13 @@
1029 case STRING_RESULT:
1030 return make_string_field(table);
1031 case DECIMAL_RESULT:
1032- field= new Field_new_decimal(
1033- my_decimal_precision_to_length(decimal_precision(),
1034- decimals,
1035- unsigned_flag),
1036- maybe_null, name, decimals, unsigned_flag);
1037+ field= new Field_new_decimal(my_decimal_precision_to_length(decimal_precision(),
1038+ decimals,
1039+ unsigned_flag),
1040+ maybe_null,
1041+ name,
1042+ decimals,
1043+ unsigned_flag);
1044 break;
1045 case ROW_RESULT:
1046 default:
1047
1048=== modified file 'drizzled/item.cc'
1049--- drizzled/item.cc 2009-08-31 23:50:37 +0000
1050+++ drizzled/item.cc 2009-09-28 07:40:31 +0000
1051@@ -1153,8 +1153,14 @@
1052
1053 switch (field_type()) {
1054 case DRIZZLE_TYPE_NEWDECIMAL:
1055- field= new Field_new_decimal((unsigned char*) 0, max_length, null_ptr, 0,
1056- Field::NONE, name, decimals, 0,
1057+ field= new Field_new_decimal((unsigned char*) 0,
1058+ max_length,
1059+ null_ptr,
1060+ 0,
1061+ Field::NONE,
1062+ name,
1063+ decimals,
1064+ 0,
1065 unsigned_flag);
1066 break;
1067 case DRIZZLE_TYPE_LONG:
1068@@ -1170,8 +1176,7 @@
1069 name, decimals, 0, unsigned_flag);
1070 break;
1071 case DRIZZLE_TYPE_NULL:
1072- field= new Field_null((unsigned char*) 0, max_length, Field::NONE,
1073- name, &my_charset_bin);
1074+ field= new Field_null((unsigned char*) 0, max_length, name, &my_charset_bin);
1075 break;
1076 case DRIZZLE_TYPE_DATE:
1077 field= new Field_date(maybe_null, name, &my_charset_bin);
1078@@ -1581,8 +1586,11 @@
1079 len-= item->decimals - dec; // corrected value fits
1080 }
1081
1082- new_field= new Field_new_decimal(len, maybe_null, item->name,
1083- dec, item->unsigned_flag);
1084+ new_field= new Field_new_decimal(len,
1085+ maybe_null,
1086+ item->name,
1087+ dec,
1088+ item->unsigned_flag);
1089 break;
1090 }
1091 case ROW_RESULT:
1092
1093=== modified file 'drizzled/item/insert_value.cc'
1094--- drizzled/item/insert_value.cc 2009-05-14 07:17:50 +0000
1095+++ drizzled/item/insert_value.cc 2009-09-28 07:40:31 +0000
1096@@ -83,8 +83,7 @@
1097 {
1098 Field *tmp_field= field_arg->field;
1099 /* charset doesn't matter here, it's to avoid sigsegv only */
1100- tmp_field= new Field_null(0, 0, Field::NONE, field_arg->field->field_name,
1101- &my_charset_bin);
1102+ tmp_field= new Field_null(0, 0, field_arg->field->field_name, &my_charset_bin);
1103 if (tmp_field)
1104 {
1105 tmp_field->init(field_arg->field->table);
1106
1107=== modified file 'drizzled/item/sum.cc'
1108--- drizzled/item/sum.cc 2009-07-31 20:29:49 +0000
1109+++ drizzled/item/sum.cc 2009-09-28 07:40:31 +0000
1110@@ -1022,8 +1022,7 @@
1111 assert(args[0]->fixed);
1112
1113 field_def.init_for_tmp_table(table_field_type, args[0]->max_length,
1114- args[0]->decimals, args[0]->maybe_null,
1115- args[0]->unsigned_flag);
1116+ args[0]->decimals, args[0]->maybe_null);
1117
1118 if (! (table= create_virtual_tmp_table(session, field_list)))
1119 return(true);
1120
1121=== modified file 'drizzled/item/type_holder.cc'
1122--- drizzled/item/type_holder.cc 2009-06-24 19:16:57 +0000
1123+++ drizzled/item/type_holder.cc 2009-09-28 07:40:31 +0000
1124@@ -232,10 +232,14 @@
1125 switch (fld_type) {
1126 case DRIZZLE_TYPE_ENUM:
1127 assert(enum_set_typelib);
1128- field= new Field_enum((unsigned char *) 0, max_length, null_ptr, 0,
1129- Field::NONE, name,
1130+ field= new Field_enum((unsigned char *) 0,
1131+ max_length,
1132+ null_ptr,
1133+ 0,
1134+ name,
1135 get_enum_pack_length(enum_set_typelib->count),
1136- enum_set_typelib, collation.collation);
1137+ enum_set_typelib,
1138+ collation.collation);
1139 if (field)
1140 field->init(table);
1141 return field;
1142
1143=== modified file 'drizzled/key.cc'
1144--- drizzled/key.cc 2009-07-30 02:39:13 +0000
1145+++ drizzled/key.cc 2009-09-28 07:40:31 +0000
1146@@ -287,8 +287,7 @@
1147 continue;
1148 }
1149 length= min((uint32_t) (key_end-key), store_length);
1150- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
1151- FIELDFLAG_PACK)))
1152+ if (key_part->field->type() == DRIZZLE_TYPE_VARCHAR)
1153 {
1154 const CHARSET_INFO * const cs= key_part->field->charset();
1155 uint32_t char_length= key_part->length / cs->mbmaxlen;
1156
1157=== modified file 'drizzled/message/table.proto'
1158--- drizzled/message/table.proto 2009-06-09 20:24:17 +0000
1159+++ drizzled/message/table.proto 2009-09-28 07:40:31 +0000
1160@@ -155,8 +155,6 @@
1161 optional string comment = 16; /* Reserve 0-15 for frequently accessed attributes */
1162 optional SetFieldOptions set_options = 17;
1163 optional TimestampFieldOptions timestamp_options = 18;
1164-
1165- optional uint32 pack_flag = 100; /* MUST DIE */
1166 }
1167
1168 message Index {
1169
1170=== modified file 'drizzled/sql_table.cc'
1171--- drizzled/sql_table.cc 2009-09-23 19:16:36 +0000
1172+++ drizzled/sql_table.cc 2009-09-28 07:40:31 +0000
1173@@ -832,27 +832,20 @@
1174
1175 switch (sql_field->sql_type) {
1176 case DRIZZLE_TYPE_BLOB:
1177- sql_field->pack_flag=FIELDFLAG_BLOB |
1178- pack_length_to_packflag(sql_field->pack_length -
1179- portable_sizeof_char_ptr);
1180- if (sql_field->charset->state & MY_CS_BINSORT)
1181- sql_field->pack_flag|=FIELDFLAG_BINARY;
1182- sql_field->length=8; // Unireg field length
1183+ sql_field->pack_flag= pack_length_to_packflag(sql_field->pack_length - portable_sizeof_char_ptr);
1184+ sql_field->length= 8; // Unireg field length
1185 (*blob_columns)++;
1186 break;
1187 case DRIZZLE_TYPE_VARCHAR:
1188 sql_field->pack_flag=0;
1189- if (sql_field->charset->state & MY_CS_BINSORT)
1190- sql_field->pack_flag|=FIELDFLAG_BINARY;
1191 break;
1192 case DRIZZLE_TYPE_ENUM:
1193- sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
1194- FIELDFLAG_INTERVAL;
1195- if (sql_field->charset->state & MY_CS_BINSORT)
1196- sql_field->pack_flag|=FIELDFLAG_BINARY;
1197- if (check_duplicates_in_interval("ENUM",sql_field->field_name,
1198- sql_field->interval,
1199- sql_field->charset, &dup_val_count))
1200+ sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length);
1201+ if (check_duplicates_in_interval("ENUM",
1202+ sql_field->field_name,
1203+ sql_field->interval,
1204+ sql_field->charset,
1205+ &dup_val_count))
1206 return 1;
1207 break;
1208 case DRIZZLE_TYPE_DATE: // Rest of string types
1209@@ -861,11 +854,7 @@
1210 sql_field->pack_flag=f_settype((uint32_t) sql_field->sql_type);
1211 break;
1212 case DRIZZLE_TYPE_NEWDECIMAL:
1213- sql_field->pack_flag=(FIELDFLAG_NUMBER |
1214- (sql_field->flags & UNSIGNED_FLAG ? 0 :
1215- FIELDFLAG_DECIMAL) |
1216- (sql_field->flags & DECIMAL_FLAG ? FIELDFLAG_DECIMAL_POSITION : 0) |
1217- (sql_field->decimals << FIELDFLAG_DEC_SHIFT));
1218+ sql_field->pack_flag= 0;
1219 break;
1220 case DRIZZLE_TYPE_TIMESTAMP:
1221 /* We should replace old TIMESTAMP fields with their newer analogs */
1222@@ -885,17 +874,10 @@
1223 (*timestamps)++;
1224 /* fall-through */
1225 default:
1226- sql_field->pack_flag=(FIELDFLAG_NUMBER |
1227- (sql_field->flags & UNSIGNED_FLAG ? 0 :
1228- FIELDFLAG_DECIMAL) |
1229- f_settype((uint32_t) sql_field->sql_type) |
1230- (sql_field->decimals << FIELDFLAG_DEC_SHIFT));
1231+ sql_field->pack_flag=(0 |
1232+ f_settype((uint32_t) sql_field->sql_type));
1233 break;
1234 }
1235- if (!(sql_field->flags & NOT_NULL_FLAG))
1236- sql_field->pack_flag|= FIELDFLAG_MAYBE_NULL;
1237- if (sql_field->flags & NO_DEFAULT_VALUE_FLAG)
1238- sql_field->pack_flag|= FIELDFLAG_NO_DEFAULT;
1239 return 0;
1240 }
1241
1242@@ -1375,45 +1357,44 @@
1243 }
1244 cols2.rewind();
1245 {
1246- column->length*= sql_field->charset->mbmaxlen;
1247+ column->length*= sql_field->charset->mbmaxlen;
1248
1249- if (f_is_blob(sql_field->pack_flag))
1250- {
1251- if (!(file->ha_table_flags() & HA_CAN_INDEX_BLOBS))
1252- {
1253- my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str);
1254- return(true);
1255- }
1256- if (!column->length)
1257- {
1258- my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str);
1259- return(true);
1260- }
1261- }
1262- if (!(sql_field->flags & NOT_NULL_FLAG))
1263- {
1264- if (key->type == Key::PRIMARY)
1265- {
1266- /* Implicitly set primary key fields to NOT NULL for ISO conf. */
1267- sql_field->flags|= NOT_NULL_FLAG;
1268- sql_field->pack_flag&= ~FIELDFLAG_MAYBE_NULL;
1269+ if (sql_field->sql_type == DRIZZLE_TYPE_BLOB)
1270+ {
1271+ if (! (file->ha_table_flags() & HA_CAN_INDEX_BLOBS))
1272+ {
1273+ my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str);
1274+ return true;
1275+ }
1276+ if (! column->length)
1277+ {
1278+ my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str);
1279+ return true;
1280+ }
1281+ }
1282+ if (! (sql_field->flags & NOT_NULL_FLAG))
1283+ {
1284+ if (key->type == Key::PRIMARY)
1285+ {
1286+ /* Implicitly set primary key fields to NOT NULL for ISO conf. */
1287+ sql_field->flags|= NOT_NULL_FLAG;
1288 null_fields--;
1289- }
1290- else
1291+ }
1292+ else
1293 {
1294 key_info->flags|= HA_NULL_PART_KEY;
1295- if (!(file->ha_table_flags() & HA_NULL_IN_KEY))
1296+ if (! (file->ha_table_flags() & HA_NULL_IN_KEY))
1297 {
1298 my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.str);
1299- return(true);
1300+ return true;
1301 }
1302 }
1303- }
1304- if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
1305- {
1306- if (column_nr == 0 || (file->ha_table_flags() & HA_AUTO_PART_KEY))
1307- auto_increment--; // Field is used
1308- }
1309+ }
1310+ if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER)
1311+ {
1312+ if (column_nr == 0 || (file->ha_table_flags() & HA_AUTO_PART_KEY))
1313+ auto_increment--; // Field is used
1314+ }
1315 }
1316
1317 key_part_info->fieldnr= field;
1318@@ -1423,7 +1404,7 @@
1319
1320 if (column->length)
1321 {
1322- if (f_is_blob(sql_field->pack_flag))
1323+ if (sql_field->sql_type == DRIZZLE_TYPE_BLOB)
1324 {
1325 if ((length=column->length) > max_key_length ||
1326 length > file->max_key_part_length())
1327@@ -1448,11 +1429,7 @@
1328 }
1329 }
1330 else if ((column->length > length ||
1331- !Field::type_can_have_key_part (sql_field->sql_type) ||
1332- ((f_is_packed(sql_field->pack_flag) ||
1333- ((file->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS) &&
1334- (key_info->flags & HA_NOSAME))) &&
1335- column->length != length)))
1336+ ! Field::type_can_have_key_part(sql_field->sql_type)))
1337 {
1338 my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0));
1339 return(true);
1340@@ -1490,13 +1467,13 @@
1341 if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) &&
1342 (length >= KEY_DEFAULT_PACK_LENGTH &&
1343 (sql_field->sql_type == DRIZZLE_TYPE_VARCHAR ||
1344- sql_field->pack_flag & FIELDFLAG_BLOB)))
1345+ sql_field->sql_type == DRIZZLE_TYPE_BLOB)))
1346 {
1347- if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) ||
1348+ if ((column_nr == 0 && sql_field->sql_type == DRIZZLE_TYPE_BLOB) ||
1349 sql_field->sql_type == DRIZZLE_TYPE_VARCHAR)
1350- key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
1351- else
1352- key_info->flags|= HA_PACK_KEY;
1353+ key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
1354+ else
1355+ key_info->flags|= HA_PACK_KEY;
1356 }
1357 /* Check if the key segment is partial, set the key flag accordingly */
1358 if (length != sql_field->key_length)
1359
1360=== modified file 'drizzled/statement/alter_table.cc'
1361--- drizzled/statement/alter_table.cc 2009-09-24 06:23:51 +0000
1362+++ drizzled/statement/alter_table.cc 2009-09-28 07:40:31 +0000
1363@@ -396,8 +396,7 @@
1364 */
1365 if (! Field::type_can_have_key_part(cfield->field->type()) ||
1366 ! Field::type_can_have_key_part(cfield->sql_type) ||
1367- (cfield->field->field_length == key_part_length &&
1368- ! f_is_blob(key_part->key_type)) ||
1369+ (cfield->field->field_length == key_part_length) ||
1370 (cfield->length &&
1371 (cfield->length < key_part_length / key_part->field->charset()->mbmaxlen)))
1372 key_part_length= 0; /* Use whole field */
1373
1374=== modified file 'drizzled/stored_key.h'
1375--- drizzled/stored_key.h 2009-07-10 00:01:50 +0000
1376+++ drizzled/stored_key.h 2009-09-28 07:40:31 +0000
1377@@ -53,9 +53,14 @@
1378 Key segments are always packed with a 2 byte length prefix.
1379 See mi_rkey for details.
1380 */
1381- to_field= new Field_varstring(ptr, length, 2, null, 1,
1382- Field::NONE, field_arg->field_name,
1383- field_arg->table->s, field_arg->charset());
1384+ to_field= new Field_varstring(ptr,
1385+ length,
1386+ 2,
1387+ null,
1388+ 1,
1389+ field_arg->field_name,
1390+ field_arg->table->s,
1391+ field_arg->charset());
1392 to_field->init(field_arg->table);
1393 }
1394 else
1395
1396=== modified file 'drizzled/table.cc'
1397--- drizzled/table.cc 2009-09-23 18:52:35 +0000
1398+++ drizzled/table.cc 2009-09-28 07:40:31 +0000
1399@@ -45,7 +45,7 @@
1400 #include <vector>
1401 #include <algorithm>
1402
1403-
1404+using namespace drizzled;
1405 using namespace std;
1406 using namespace drizzled;
1407
1408@@ -282,7 +282,7 @@
1409 int error= 0;
1410 handler *handler_file= NULL;
1411
1412- share->setTableProto(new(std::nothrow) message::Table(table));
1413+ share->setTableProto(new(nothrow) message::Table(table));
1414
1415 share->storage_engine= ha_resolve_by_name(session, table.engine().name());
1416
1417@@ -386,36 +386,35 @@
1418 {
1419 message::Table::Index::IndexOptions indx_options= indx.options();
1420 if (indx_options.pack_key())
1421- keyinfo->flags|= HA_PACK_KEY;
1422+ keyinfo->flags|= HA_PACK_KEY;
1423
1424 if (indx_options.var_length_key())
1425- keyinfo->flags|= HA_VAR_LENGTH_PART;
1426+ keyinfo->flags|= HA_VAR_LENGTH_PART;
1427
1428 if (indx_options.null_part_key())
1429- keyinfo->flags|= HA_NULL_PART_KEY;
1430+ keyinfo->flags|= HA_NULL_PART_KEY;
1431
1432 if (indx_options.binary_pack_key())
1433- keyinfo->flags|= HA_BINARY_PACK_KEY;
1434+ keyinfo->flags|= HA_BINARY_PACK_KEY;
1435
1436 if (indx_options.has_partial_segments())
1437- keyinfo->flags|= HA_KEY_HAS_PART_KEY_SEG;
1438+ keyinfo->flags|= HA_KEY_HAS_PART_KEY_SEG;
1439
1440 if (indx_options.auto_generated_key())
1441- keyinfo->flags|= HA_GENERATED_KEY;
1442+ keyinfo->flags|= HA_GENERATED_KEY;
1443
1444 if (indx_options.has_key_block_size())
1445 {
1446- keyinfo->flags|= HA_USES_BLOCK_SIZE;
1447- keyinfo->block_size= indx_options.key_block_size();
1448+ keyinfo->flags|= HA_USES_BLOCK_SIZE;
1449+ keyinfo->block_size= indx_options.key_block_size();
1450 }
1451 else
1452 {
1453- keyinfo->block_size= 0;
1454+ keyinfo->block_size= 0;
1455 }
1456-
1457 }
1458
1459- switch(indx.type())
1460+ switch (indx.type())
1461 {
1462 case message::Table::Index::UNKNOWN_INDEX:
1463 keyinfo->algorithm= HA_KEY_ALG_UNDEF;
1464@@ -446,8 +445,8 @@
1465 keyinfo->rec_per_key= rec_per_key;
1466
1467 for (unsigned int partnr= 0;
1468- partnr < keyinfo->key_parts;
1469- partnr++, key_part++)
1470+ partnr < keyinfo->key_parts;
1471+ partnr++, key_part++)
1472 {
1473 message::Table::Index::IndexPart part;
1474 part= indx.index_part(partnr);
1475@@ -462,7 +461,7 @@
1476 /* key_part->type ???? */
1477 key_part->key_part_flag= 0;
1478 if (part.has_in_reverse_order())
1479- key_part->key_part_flag= part.in_reverse_order()? HA_REVERSE_SORT : 0;
1480+ key_part->key_part_flag= part.in_reverse_order()? HA_REVERSE_SORT : 0;
1481
1482 key_part->length= part.compare_length();
1483
1484@@ -470,10 +469,9 @@
1485
1486 /* key_part->offset is set later */
1487 key_part->key_type= part.key_type();
1488-
1489 }
1490
1491- if (!indx.has_comment())
1492+ if (! indx.has_comment())
1493 {
1494 keyinfo->comment.length= 0;
1495 keyinfo->comment.str= NULL;
1496@@ -549,38 +547,34 @@
1497 case DRIZZLE_TYPE_BLOB:
1498 case DRIZZLE_TYPE_VARCHAR:
1499 {
1500- message::Table::Field::StringFieldOptions field_options=
1501- pfield.string_options();
1502-
1503- const CHARSET_INFO *cs= get_charset(field_options.has_collation_id()?
1504- field_options.collation_id() : 0);
1505-
1506- if (!cs)
1507- cs= default_charset_info;
1508-
1509- field_pack_length[fieldnr]=
1510- calc_pack_length(drizzle_field_type,
1511- field_options.length() * cs->mbmaxlen);
1512-
1513+ message::Table::Field::StringFieldOptions field_options= pfield.string_options();
1514+
1515+ const CHARSET_INFO *cs= get_charset(field_options.has_collation_id() ?
1516+ field_options.collation_id() : 0);
1517+
1518+ if (! cs)
1519+ cs= default_charset_info;
1520+
1521+ field_pack_length[fieldnr]= calc_pack_length(drizzle_field_type,
1522+ field_options.length() * cs->mbmaxlen);
1523 }
1524 break;
1525 case DRIZZLE_TYPE_ENUM:
1526 {
1527- message::Table::Field::SetFieldOptions field_options=
1528- pfield.set_options();
1529-
1530- field_pack_length[fieldnr]=
1531- get_enum_pack_length(field_options.field_value_size());
1532-
1533- interval_count++;
1534- interval_parts+= field_options.field_value_size();
1535+ message::Table::Field::SetFieldOptions field_options= pfield.set_options();
1536+
1537+ field_pack_length[fieldnr]=
1538+ get_enum_pack_length(field_options.field_value_size());
1539+
1540+ interval_count++;
1541+ interval_parts+= field_options.field_value_size();
1542 }
1543 break;
1544 case DRIZZLE_TYPE_NEWDECIMAL:
1545 {
1546- message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
1547- field_pack_length[fieldnr]=
1548- my_decimal_get_binary_size(fo.precision(), fo.scale());
1549+ message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
1550+
1551+ field_pack_length[fieldnr]= my_decimal_get_binary_size(fo.precision(), fo.scale());
1552 }
1553 break;
1554 default:
1555@@ -590,7 +584,6 @@
1556
1557 share->reclength+= field_pack_length[fieldnr];
1558 stored_columns_reclength+= field_pack_length[fieldnr];
1559-
1560 }
1561
1562 /* data_offset added to stored_rec_length later */
1563@@ -599,7 +592,7 @@
1564 share->null_fields= null_fields;
1565
1566 ulong null_bits= null_fields;
1567- if (!table_options.pack_record())
1568+ if (! table_options.pack_record())
1569 null_bits++;
1570 ulong data_offset= (null_bits + 7)/8;
1571
1572@@ -614,15 +607,15 @@
1573
1574 unsigned char* record= NULL;
1575
1576- if (!(record= (unsigned char *) alloc_root(&share->mem_root,
1577- rec_buff_length)))
1578+ if (! (record= (unsigned char *) alloc_root(&share->mem_root,
1579+ rec_buff_length)))
1580 abort();
1581
1582 memset(record, 0, rec_buff_length);
1583
1584 int null_count= 0;
1585
1586- if (!table_options.pack_record())
1587+ if (! table_options.pack_record())
1588 {
1589 null_count++; // one bit for delete mark.
1590 *record|= 1;
1591@@ -632,17 +625,17 @@
1592
1593 if (interval_count)
1594 {
1595- share->intervals= (TYPELIB*)alloc_root(&share->mem_root,
1596- interval_count*sizeof(TYPELIB));
1597+ share->intervals= (TYPELIB *) alloc_root(&share->mem_root,
1598+ interval_count*sizeof(TYPELIB));
1599 }
1600 else
1601 share->intervals= NULL;
1602
1603- share->fieldnames.type_names= (const char**)alloc_root(&share->mem_root,
1604- (share->fields+1)*sizeof(char*));
1605+ share->fieldnames.type_names= (const char **) alloc_root(&share->mem_root,
1606+ (share->fields + 1) * sizeof(char*));
1607
1608- share->fieldnames.type_lengths= (unsigned int*) alloc_root(&share->mem_root,
1609- (share->fields+1)*sizeof(unsigned int));
1610+ share->fieldnames.type_lengths= (unsigned int *) alloc_root(&share->mem_root,
1611+ (share->fields + 1) * sizeof(unsigned int));
1612
1613 share->fieldnames.type_names[share->fields]= NULL;
1614 share->fieldnames.type_lengths[share->fields]= 0;
1615@@ -661,8 +654,8 @@
1616
1617 /* field names */
1618 share->fieldnames.type_names[fieldnr]= strmake_root(&share->mem_root,
1619- pfield.name().c_str(),
1620- pfield.name().length());
1621+ pfield.name().c_str(),
1622+ pfield.name().length());
1623
1624 share->fieldnames.type_lengths[fieldnr]= pfield.name().length();
1625
1626@@ -672,19 +665,19 @@
1627
1628 message::Table::Field::SetFieldOptions field_options= pfield.set_options();
1629
1630- const CHARSET_INFO *charset= get_charset(field_options.has_collation_id()?
1631- field_options.collation_id() : 0);
1632+ const CHARSET_INFO *charset= get_charset(field_options.has_collation_id() ?
1633+ field_options.collation_id() : 0);
1634
1635- if (!charset)
1636+ if (! charset)
1637 charset= default_charset_info;
1638
1639 TYPELIB *t= &(share->intervals[interval_nr]);
1640
1641 t->type_names= (const char**)alloc_root(&share->mem_root,
1642- (field_options.field_value_size()+1)*sizeof(char*));
1643+ (field_options.field_value_size() + 1) * sizeof(char*));
1644
1645 t->type_lengths= (unsigned int*) alloc_root(&share->mem_root,
1646- (field_options.field_value_size()+1)*sizeof(unsigned int));
1647+ (field_options.field_value_size() + 1) * sizeof(unsigned int));
1648
1649 t->type_names[field_options.field_value_size()]= NULL;
1650 t->type_lengths[field_options.field_value_size()]= 0;
1651@@ -695,15 +688,17 @@
1652 for (int n= 0; n < field_options.field_value_size(); n++)
1653 {
1654 t->type_names[n]= strmake_root(&share->mem_root,
1655- field_options.field_value(n).c_str(),
1656- field_options.field_value(n).length());
1657+ field_options.field_value(n).c_str(),
1658+ field_options.field_value(n).length());
1659
1660- /* Go ask the charset what the length is as for "" length=1
1661- and there's stripping spaces or some other crack going on.
1662+ /*
1663+ * Go ask the charset what the length is as for "" length=1
1664+ * and there's stripping spaces or some other crack going on.
1665 */
1666 uint32_t lengthsp;
1667- lengthsp= charset->cset->lengthsp(charset, t->type_names[n],
1668- field_options.field_value(n).length());
1669+ lengthsp= charset->cset->lengthsp(charset,
1670+ t->type_names[n],
1671+ field_options.field_value(n).length());
1672 t->type_lengths[n]= lengthsp;
1673 }
1674 interval_nr++;
1675@@ -716,10 +711,14 @@
1676 bool use_hash= share->fields >= MAX_FIELDS_BEFORE_HASH;
1677
1678 if (use_hash)
1679- use_hash= !hash_init(&share->name_hash,
1680- system_charset_info,
1681- share->fields, 0, 0,
1682- (hash_get_key) get_field_name, 0, 0);
1683+ use_hash= ! hash_init(&share->name_hash,
1684+ system_charset_info,
1685+ share->fields,
1686+ 0,
1687+ 0,
1688+ (hash_get_key) get_field_name,
1689+ 0,
1690+ 0);
1691
1692 unsigned char* null_pos= record;;
1693 int null_bit_pos= (table_options.pack_record()) ? 0 : 1;
1694@@ -730,7 +729,7 @@
1695
1696 enum column_format_type column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1697
1698- switch(pfield.format())
1699+ switch (pfield.format())
1700 {
1701 case message::Table::Field::DefaultFormat:
1702 column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1703@@ -747,31 +746,31 @@
1704
1705 Field::utype unireg_type= Field::NONE;
1706
1707- if (pfield.has_numeric_options()
1708- && pfield.numeric_options().is_autoincrement())
1709+ if (pfield.has_numeric_options() &&
1710+ pfield.numeric_options().is_autoincrement())
1711 {
1712 unireg_type= Field::NEXT_NUMBER;
1713 }
1714
1715- if (pfield.has_options()
1716- && pfield.options().has_default_value()
1717- && pfield.options().default_value().compare("NOW()") == 0)
1718+ if (pfield.has_options() &&
1719+ pfield.options().has_default_value() &&
1720+ pfield.options().default_value().compare("NOW()") == 0)
1721 {
1722- if (pfield.options().has_update_value()
1723- && pfield.options().update_value().compare("NOW()") == 0)
1724+ if (pfield.options().has_update_value() &&
1725+ pfield.options().update_value().compare("NOW()") == 0)
1726 {
1727- unireg_type= Field::TIMESTAMP_DNUN_FIELD;
1728+ unireg_type= Field::TIMESTAMP_DNUN_FIELD;
1729 }
1730- else if (!pfield.options().has_update_value())
1731+ else if (! pfield.options().has_update_value())
1732 {
1733- unireg_type= Field::TIMESTAMP_DN_FIELD;
1734+ unireg_type= Field::TIMESTAMP_DN_FIELD;
1735 }
1736 else
1737- assert(1); // Invalid update value.
1738+ assert(1); // Invalid update value.
1739 }
1740- else if (pfield.has_options()
1741- && pfield.options().has_update_value()
1742- && pfield.options().update_value().compare("NOW()") == 0)
1743+ else if (pfield.has_options() &&
1744+ pfield.options().has_update_value() &&
1745+ pfield.options().update_value().compare("NOW()") == 0)
1746 {
1747 unireg_type= Field::TIMESTAMP_UN_FIELD;
1748 }
1749@@ -797,47 +796,67 @@
1750
1751 const CHARSET_INFO *charset= &my_charset_bin;
1752
1753- if (field_type==DRIZZLE_TYPE_BLOB
1754- || field_type==DRIZZLE_TYPE_VARCHAR)
1755- {
1756- message::Table::Field::StringFieldOptions field_options=
1757- pfield.string_options();
1758-
1759- charset= get_charset(field_options.has_collation_id()?
1760- field_options.collation_id() : 0);
1761-
1762- if (!charset)
1763- charset= default_charset_info;
1764-
1765- }
1766-
1767- if (field_type==DRIZZLE_TYPE_ENUM)
1768- {
1769- message::Table::Field::SetFieldOptions field_options=
1770- pfield.set_options();
1771-
1772- charset= get_charset(field_options.has_collation_id()?
1773- field_options.collation_id() : 0);
1774-
1775- if (!charset)
1776- charset= default_charset_info;
1777-
1778+ if (field_type == DRIZZLE_TYPE_BLOB ||
1779+ field_type == DRIZZLE_TYPE_VARCHAR)
1780+ {
1781+ message::Table::Field::StringFieldOptions field_options= pfield.string_options();
1782+
1783+ charset= get_charset(field_options.has_collation_id() ?
1784+ field_options.collation_id() : 0);
1785+
1786+ if (! charset)
1787+ charset= default_charset_info;
1788+ }
1789+
1790+ if (field_type == DRIZZLE_TYPE_ENUM)
1791+ {
1792+ message::Table::Field::SetFieldOptions field_options= pfield.set_options();
1793+
1794+ charset= get_charset(field_options.has_collation_id()?
1795+ field_options.collation_id() : 0);
1796+
1797+ if (! charset)
1798+ charset= default_charset_info;
1799+ }
1800+
1801+ uint8_t decimals= 0;
1802+ if (field_type == DRIZZLE_TYPE_NEWDECIMAL
1803+ || field_type == DRIZZLE_TYPE_DOUBLE)
1804+ {
1805+ message::Table::Field::NumericFieldOptions fo= pfield.numeric_options();
1806+
1807+ if (! pfield.has_numeric_options() || ! fo.has_scale())
1808+ {
1809+ /*
1810+ We don't write the default to table proto so
1811+ if no decimals specified for DOUBLE, we use the default.
1812+ */
1813+ decimals= NOT_FIXED_DEC;
1814+ }
1815+ else
1816+ {
1817+ if (fo.scale() > DECIMAL_MAX_SCALE)
1818+ {
1819+ error= 4;
1820+ goto err;
1821+ }
1822+ decimals= fo.scale();
1823+ }
1824 }
1825
1826 Item *default_value= NULL;
1827
1828- if (pfield.options().has_default_value()
1829- || pfield.options().has_default_null()
1830- || pfield.options().has_default_bin_value())
1831+ if (pfield.options().has_default_value() ||
1832+ pfield.options().has_default_null() ||
1833+ pfield.options().has_default_bin_value())
1834 {
1835 default_value= default_value_item(field_type,
1836- charset,
1837- pfield.options().default_null(),
1838- &pfield.options().default_value(),
1839- &pfield.options().default_bin_value());
1840+ charset,
1841+ pfield.options().default_null(),
1842+ &pfield.options().default_value(),
1843+ &pfield.options().default_bin_value());
1844 }
1845
1846- uint32_t pack_flag= pfield.pack_flag(); /* TODO: MUST DIE */
1847
1848 Table temp_table; /* Use this so that BLOB DEFAULT '' works */
1849 memset(&temp_table, 0, sizeof(temp_table));
1850@@ -846,29 +865,31 @@
1851 temp_table.s->db_low_byte_first= 1; //handler->low_byte_first();
1852 temp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
1853
1854- Field* f= make_field(share, &share->mem_root,
1855- record+field_offsets[fieldnr]+data_offset,
1856- pfield.options().length(),
1857- null_pos,
1858- null_bit_pos,
1859- pack_flag,
1860- field_type,
1861- charset,
1862- (Field::utype) MTYP_TYPENR(unireg_type),
1863- ((field_type==DRIZZLE_TYPE_ENUM)?
1864- share->intervals+(interval_nr++)
1865- : (TYPELIB*) 0),
1866- share->fieldnames.type_names[fieldnr]);
1867+ Field* f= make_field(share,
1868+ &share->mem_root,
1869+ record + field_offsets[fieldnr] + data_offset,
1870+ pfield.options().length(),
1871+ pfield.has_constraints() && pfield.constraints().is_nullable() ? true : false,
1872+ null_pos,
1873+ null_bit_pos,
1874+ decimals,
1875+ field_type,
1876+ charset,
1877+ (Field::utype) MTYP_TYPENR(unireg_type),
1878+ ((field_type == DRIZZLE_TYPE_ENUM) ?
1879+ share->intervals + (interval_nr++)
1880+ : (TYPELIB*) 0),
1881+ share->fieldnames.type_names[fieldnr]);
1882
1883 share->field[fieldnr]= f;
1884
1885 f->init(&temp_table); /* blob default values need table obj */
1886
1887- if (!(f->flags & NOT_NULL_FLAG))
1888+ if (! (f->flags & NOT_NULL_FLAG))
1889 {
1890 *f->null_ptr|= f->null_bit;
1891- if (!(null_bit_pos= (null_bit_pos + 1) & 7))
1892- null_pos++;
1893+ if (! (null_bit_pos= (null_bit_pos + 1) & 7)) /* @TODO Ugh. */
1894+ null_pos++;
1895 null_count++;
1896 }
1897
1898@@ -878,15 +899,15 @@
1899 session->count_cuted_fields= CHECK_FIELD_WARN;
1900 int res= default_value->save_in_field(f, 1);
1901 session->count_cuted_fields= old_count_cuted_fields;
1902- if (res != 0 && res != 3)
1903+ if (res != 0 && res != 3) /* @TODO Huh? */
1904 {
1905 my_error(ER_INVALID_DEFAULT, MYF(0), f->field_name);
1906 error= 1;
1907- goto err;
1908+ goto err;
1909 }
1910 }
1911 else if (f->real_type() == DRIZZLE_TYPE_ENUM &&
1912- (f->flags & NOT_NULL_FLAG))
1913+ (f->flags & NOT_NULL_FLAG))
1914 {
1915 f->set_notnull();
1916 f->store((int64_t) 1, true);
1917@@ -900,11 +921,13 @@
1918
1919 f->field_index= fieldnr;
1920 f->comment= comment;
1921- if (!default_value
1922- && !(f->unireg_check==Field::NEXT_NUMBER)
1923- && (f->flags & NOT_NULL_FLAG)
1924- && (f->real_type() != DRIZZLE_TYPE_TIMESTAMP))
1925+ if (! default_value &&
1926+ ! (f->unireg_check==Field::NEXT_NUMBER) &&
1927+ (f->flags & NOT_NULL_FLAG) &&
1928+ (f->real_type() != DRIZZLE_TYPE_TIMESTAMP))
1929+ {
1930 f->flags|= NO_DEFAULT_VALUE_FLAG;
1931+ }
1932
1933 if (f->unireg_check == Field::NEXT_NUMBER)
1934 share->found_next_number_field= &(share->field[fieldnr]);
1935@@ -927,9 +950,11 @@
1936 partnr < keyinfo->key_parts;
1937 partnr++, key_part++)
1938 {
1939- /* Fix up key_part->offset by adding data_offset.
1940- We really should compute offset as well.
1941- But at least this way we are a little better. */
1942+ /*
1943+ * Fix up key_part->offset by adding data_offset.
1944+ * We really should compute offset as well.
1945+ * But at least this way we are a little better.
1946+ */
1947 key_part->offset= field_offsets[key_part->fieldnr-1] + data_offset;
1948 }
1949 }
1950@@ -942,61 +967,59 @@
1951 if (null_count & 7)
1952 *(record + null_count / 8)|= ~(((unsigned char) 1 << (null_count & 7)) - 1);
1953
1954- share->null_bytes= (null_pos - (unsigned char*) record +
1955- (null_bit_pos + 7) / 8);
1956+ share->null_bytes= (null_pos - (unsigned char*) record + (null_bit_pos + 7) / 8);
1957
1958 share->last_null_bit_pos= null_bit_pos;
1959
1960 free(field_offsets);
1961 free(field_pack_length);
1962
1963- if (!(handler_file= get_new_handler(share, session->mem_root,
1964- share->db_type())))
1965+ if (! (handler_file= get_new_handler(share,
1966+ session->mem_root,
1967+ share->db_type())))
1968 abort(); // FIXME
1969
1970 /* Fix key stuff */
1971 if (share->key_parts)
1972 {
1973- uint32_t primary_key=(uint32_t) (find_type((char*) "PRIMARY",
1974- &share->keynames, 3) - 1);
1975+ uint32_t primary_key= (uint32_t) (find_type((char*) "PRIMARY",
1976+ &share->keynames, 3) - 1); /* @TODO Huh? */
1977
1978 int64_t ha_option= handler_file->ha_table_flags();
1979
1980 keyinfo= share->key_info;
1981 key_part= keyinfo->key_part;
1982
1983- for (uint32_t key= 0 ; key < share->keys ; key++,keyinfo++)
1984+ for (uint32_t key= 0; key < share->keys; key++,keyinfo++)
1985 {
1986 uint32_t usable_parts= 0;
1987
1988 if (primary_key >= MAX_KEY && (keyinfo->flags & HA_NOSAME))
1989 {
1990- /*
1991- If the UNIQUE key doesn't have NULL columns and is not a part key
1992- declare this as a primary key.
1993- */
1994- primary_key=key;
1995- for (uint32_t i= 0 ; i < keyinfo->key_parts ;i++)
1996- {
1997- uint32_t fieldnr= key_part[i].fieldnr;
1998- if (!fieldnr ||
1999- share->field[fieldnr-1]->null_ptr ||
2000- share->field[fieldnr-1]->key_length() !=
2001- key_part[i].length)
2002- {
2003- primary_key=MAX_KEY; // Can't be used
2004- break;
2005- }
2006- }
2007+ /*
2008+ If the UNIQUE key doesn't have NULL columns and is not a part key
2009+ declare this as a primary key.
2010+ */
2011+ primary_key=key;
2012+ for (uint32_t i= 0; i < keyinfo->key_parts; i++)
2013+ {
2014+ uint32_t fieldnr= key_part[i].fieldnr;
2015+ if (! fieldnr ||
2016+ share->field[fieldnr-1]->null_ptr ||
2017+ share->field[fieldnr-1]->key_length() != key_part[i].length)
2018+ {
2019+ primary_key= MAX_KEY; // Can't be used
2020+ break;
2021+ }
2022+ }
2023 }
2024
2025 for (uint32_t i= 0 ; i < keyinfo->key_parts ; key_part++,i++)
2026 {
2027 Field *field;
2028- if (!key_part->fieldnr)
2029+ if (! key_part->fieldnr)
2030 {
2031-// error= 4; // Wrong file
2032- abort(); // goto err;
2033+ abort(); // goto err;
2034 }
2035 field= key_part->field= share->field[key_part->fieldnr-1];
2036 key_part->type= field->key_type();
2037@@ -1076,24 +1099,23 @@
2038 set_if_bigger(share->max_unique_length,keyinfo->key_length);
2039 }
2040 if (primary_key < MAX_KEY &&
2041- (share->keys_in_use.test(primary_key)))
2042+ (share->keys_in_use.test(primary_key)))
2043 {
2044 share->primary_key= primary_key;
2045 /*
2046- If we are using an integer as the primary key then allow the user to
2047- refer to it as '_rowid'
2048+ If we are using an integer as the primary key then allow the user to
2049+ refer to it as '_rowid'
2050 */
2051 if (share->key_info[primary_key].key_parts == 1)
2052 {
2053- Field *field= share->key_info[primary_key].key_part[0].field;
2054- if (field && field->result_type() == INT_RESULT)
2055+ Field *field= share->key_info[primary_key].key_part[0].field;
2056+ if (field && field->result_type() == INT_RESULT)
2057 {
2058 /* note that fieldnr here (and rowid_field_offset) starts from 1 */
2059- share->rowid_field_offset= (share->key_info[primary_key].key_part[0].
2060+ share->rowid_field_offset= (share->key_info[primary_key].key_part[0].
2061 fieldnr);
2062 }
2063 }
2064-
2065 }
2066 else
2067 share->primary_key = MAX_KEY; // we do not have a primary key
2068@@ -1131,7 +1153,7 @@
2069 for (k= 0, ptr= share->field ; *ptr ; ptr++, k++)
2070 {
2071 if ((*ptr)->flags & BLOB_FLAG)
2072- (*save++)= k;
2073+ (*save++)= k;
2074 }
2075 }
2076
2077@@ -2770,11 +2792,11 @@
2078 key_part_info->offset= field->offset(table->record[0]);
2079 key_part_info->length= (uint16_t) field->key_length();
2080 key_part_info->type= (uint8_t) field->key_type();
2081- key_part_info->key_type =
2082+ key_part_info->key_type=
2083 ((ha_base_keytype) key_part_info->type == HA_KEYTYPE_TEXT ||
2084 (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT1 ||
2085 (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT2) ?
2086- 0 : FIELDFLAG_BINARY;
2087+ 0 : 1;
2088 if (!using_unique_constraint)
2089 {
2090 cur_group->buff=(char*) group_buff;
2091@@ -2857,14 +2879,13 @@
2092 0,
2093 (unsigned char*) 0,
2094 (uint32_t) 0,
2095- Field::NONE,
2096 NULL,
2097 table->s,
2098 &my_charset_bin);
2099 if (!key_part_info->field)
2100 goto err;
2101 key_part_info->field->init(table);
2102- key_part_info->key_type=FIELDFLAG_BINARY;
2103+ key_part_info->key_type= 1; /* binary comparison */
2104 key_part_info->type= HA_KEYTYPE_BINARY;
2105 key_part_info++;
2106 }
2107@@ -2898,7 +2919,7 @@
2108 ((ha_base_keytype) key_part_info->type == HA_KEYTYPE_TEXT ||
2109 (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT1 ||
2110 (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT2) ?
2111- 0 : FIELDFLAG_BINARY;
2112+ 0 : 1;
2113 }
2114 }
2115
2116@@ -2981,12 +3002,19 @@
2117 List_iterator_fast<CreateField> it(field_list);
2118 while ((cdef= it++))
2119 {
2120- *field= make_field(share, NULL, 0, cdef->length,
2121- (unsigned char*) (f_maybe_null(cdef->pack_flag) ? "" : 0),
2122- f_maybe_null(cdef->pack_flag) ? 1 : 0,
2123- cdef->pack_flag, cdef->sql_type, cdef->charset,
2124+ *field= make_field(share,
2125+ NULL,
2126+ 0,
2127+ cdef->length,
2128+ (cdef->flags & NOT_NULL_FLAG) ? false : true,
2129+ (unsigned char *) ((cdef->flags & NOT_NULL_FLAG) ? 0 : ""),
2130+ (cdef->flags & NOT_NULL_FLAG) ? 0 : 1,
2131+ cdef->decimals,
2132+ cdef->sql_type,
2133+ cdef->charset,
2134 cdef->unireg_check,
2135- cdef->interval, cdef->field_name);
2136+ cdef->interval,
2137+ cdef->field_name);
2138 if (!*field)
2139 goto error;
2140 (*field)->init(table);
2141@@ -3151,8 +3179,7 @@
2142 seg->start= keyinfo->key_part[i].offset;
2143 if (key_field->flags & BLOB_FLAG)
2144 {
2145- seg->type=
2146- ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ?
2147+ seg->type= ((keyinfo->key_part[i].key_type & 1 /* binary */) ?
2148 HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2);
2149 seg->bit_start= (uint8_t)(key_field->pack_length()
2150 - share->blob_ptr_size);
2151
2152=== modified file 'drizzled/table_proto_write.cc'
2153--- drizzled/table_proto_write.cc 2009-09-16 20:58:28 +0000
2154+++ drizzled/table_proto_write.cc 2009-09-28 07:40:31 +0000
2155@@ -59,9 +59,7 @@
2156 attribute= table_proto->add_field();
2157 attribute->set_name(field_arg->field_name);
2158
2159- attribute->set_pack_flag(field_arg->pack_flag); /* TODO: MUST DIE */
2160-
2161- if(f_maybe_null(field_arg->pack_flag))
2162+ if(! (field_arg->flags & NOT_NULL_FLAG))
2163 {
2164 message::Table::Field::FieldConstraints *constraints;
2165
2166@@ -77,7 +75,37 @@
2167 attribute->set_type(message::Table::Field::INTEGER);
2168 break;
2169 case DRIZZLE_TYPE_DOUBLE:
2170- attribute->set_type(message::Table::Field::DOUBLE);
2171+ {
2172+ attribute->set_type(drizzled::message::Table::Field::DOUBLE);
2173+
2174+ /*
2175+ * For DOUBLE, we only add a specific scale and precision iff
2176+ * the fixed decimal point has been specified...
2177+ */
2178+ if (field_arg->decimals != NOT_FIXED_DEC)
2179+ {
2180+ drizzled::message::Table::Field::NumericFieldOptions *numeric_field_options;
2181+
2182+ numeric_field_options= attribute->mutable_numeric_options();
2183+ /*
2184+ * Precision and scale are specified like so:
2185+ *
2186+ * DOUBLE(P,S)
2187+ *
2188+ * From the CreateField, we get the "length", which is the *total* length
2189+ * of the double storage space, including the decimal point if there is a
2190+ * scale argument and a 1 byte length header. We also get the "decimals",
2191+ * which is actually the scale (the number of numbers stored after the decimal point)
2192+ *
2193+ * Therefore, PRECISION= LENGTH - 1 - (SCALE ? SCALE + 1 : 0)
2194+ */
2195+ if (field_arg->decimals)
2196+ numeric_field_options->set_precision(field_arg->length - 2); /* One for the decimal, one for the header */
2197+ else
2198+ numeric_field_options->set_precision(field_arg->length - 1); /* for the header */
2199+ numeric_field_options->set_scale(field_arg->decimals);
2200+ }
2201+ }
2202 break;
2203 case DRIZZLE_TYPE_NULL :
2204 assert(1); /* Not a user definable type */
2205
2206=== modified file 'plugin/innobase/handler/handler0alter.cc'
2207--- plugin/innobase/handler/handler0alter.cc 2009-06-08 19:10:56 +0000
2208+++ plugin/innobase/handler/handler0alter.cc 2009-09-28 07:40:31 +0000
2209@@ -520,8 +520,7 @@
2210 new_primary = TRUE;
2211
2212 while (key_part--) {
2213- if (key_info->key_part[key_part].key_type
2214- & FIELDFLAG_MAYBE_NULL) {
2215+ if (key_info->key_part[key_part].null_bit == 0) {
2216 new_primary = FALSE;
2217 break;
2218 }