Below is the list of changes that have just been committed into a local
5.0 repository of dlenev. When dlenev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-10-18 15:28:20+04:00, dlenev@stripped +3 -0
Proposed fix for bug#15228 "'invalid access to non-static data member'
warnings in sql_trigger.cc and sql_view.cc".
According to the current version of C++ stnadard offsetof() macro
can't be used for non-POD types. So warnings were emitted when we
tried to use this macro for TABLE_LIST and Table_triggers_list
classes. Note that despite of these warnings it was probably safe
thing to do.
This fix tries to circumvent this limitation by using dummy
instances of these classes (we assume that all instances of
those classes has same offsets for same members). This hack
should go away once we will refactor File_parser class.
Alternative approaches such as disabling this warning for
sql_trigger.cc/sql_view.cc or for the whole server were
considered less explicit. Also I was unable to find a way
to disable particular warning for particular _part_ of
file in GCC.
sql/parse_file.h@stripped, 2006-10-18 15:28:17+04:00, dlenev@stripped +12 -0
Introduced auxillary macro which can be used to get offsets of
members in class for non-POD types (assuming that all instances
of the class has same offsets for same members).
sql/sql_trigger.cc@stripped, 2006-10-18 15:28:17+04:00, dlenev@stripped +16 -4
To circumvent limitation of offset() macro (it can't be used for
non-POD types) we have to create dummy Table_triggers_list object
to get offsets of its members for File_parser.
sql/sql_view.cc@stripped, 2006-10-18 15:28:17+04:00, dlenev@stripped +20 -12
To circumvent limitation of offset() macro (it can't be used for
non-POD types) we have to create dummy TABLE_LIST object to get
offsets of its members for File_parser.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: dlenev
# Host: mockturtle.local
# Root: /home/dlenev/src/mysql-5.0-bg15228
--- 1.12/sql/parse_file.h 2006-10-18 15:28:25 +04:00
+++ 1.13/sql/parse_file.h 2006-10-18 15:28:25 +04:00
@@ -107,4 +107,16 @@
bool bad_format_errors);
};
+
+/*
+ Auxillary macro which can be used to get offsets of members in
+ class for non-POD types (we can't use use offsetof() macro in such
+ cases according to the current version of C++ standard, but probably
+ it is still OK to assume that all instances of the class has the
+ same offsets for the same members in many cases).
+*/
+
+#define offsetof_in_object(OBJECT, MEMBER) \
+ ((size_t) ((char *)&(OBJECT.MEMBER) - (char*)&OBJECT))
+
#endif /* _PARSE_FILE_H_ */
--- 1.90/sql/sql_view.cc 2006-10-18 15:28:25 +04:00
+++ 1.91/sql/sql_view.cc 2006-10-18 15:28:25 +04:00
@@ -501,6 +501,14 @@
static const int num_view_backups= 3;
/*
+ To circumvent limitation of offset() macro we have to create dummy
+ TABLE_LIST object to get offsets of its members for File_parser.
+ See comment in sql_trigger.cc for more information.
+*/
+
+static TABLE_LIST dummy;
+
+/*
table of VIEW .frm field descriptors
Note that one should NOT change the order for this, as it's used by
@@ -508,40 +516,40 @@
*/
static File_option view_parameters[]=
{{{(char*) STRING_WITH_LEN("query")},
- offsetof(TABLE_LIST, query),
+ offsetof_in_object(dummy, query),
FILE_OPTIONS_ESTRING},
{{(char*) STRING_WITH_LEN("md5")},
- offsetof(TABLE_LIST, md5),
+ offsetof_in_object(dummy, md5),
FILE_OPTIONS_STRING},
{{(char*) STRING_WITH_LEN("updatable")},
- offsetof(TABLE_LIST, updatable_view),
+ offsetof_in_object(dummy, updatable_view),
FILE_OPTIONS_ULONGLONG},
{{(char*) STRING_WITH_LEN("algorithm")},
- offsetof(TABLE_LIST, algorithm),
+ offsetof_in_object(dummy, algorithm),
FILE_OPTIONS_ULONGLONG},
{{(char*) STRING_WITH_LEN("definer_user")},
- offsetof(TABLE_LIST, definer.user),
+ offsetof_in_object(dummy, definer.user),
FILE_OPTIONS_STRING},
{{(char*) STRING_WITH_LEN("definer_host")},
- offsetof(TABLE_LIST, definer.host),
+ offsetof_in_object(dummy, definer.host),
FILE_OPTIONS_STRING},
{{(char*) STRING_WITH_LEN("suid")},
- offsetof(TABLE_LIST, view_suid),
+ offsetof_in_object(dummy, view_suid),
FILE_OPTIONS_ULONGLONG},
{{(char*) STRING_WITH_LEN("with_check_option")},
- offsetof(TABLE_LIST, with_check),
+ offsetof_in_object(dummy, with_check),
FILE_OPTIONS_ULONGLONG},
{{(char*) STRING_WITH_LEN("revision")},
- offsetof(TABLE_LIST, revision),
+ offsetof_in_object(dummy, revision),
FILE_OPTIONS_REV},
{{(char*) STRING_WITH_LEN("timestamp")},
- offsetof(TABLE_LIST, timestamp),
+ offsetof_in_object(dummy, timestamp),
FILE_OPTIONS_TIMESTAMP},
{{(char*)STRING_WITH_LEN("create-version")},
- offsetof(TABLE_LIST, file_version),
+ offsetof_in_object(dummy, file_version),
FILE_OPTIONS_ULONGLONG},
{{(char*) STRING_WITH_LEN("source")},
- offsetof(TABLE_LIST, source),
+ offsetof_in_object(dummy, source),
FILE_OPTIONS_ESTRING},
{{NullS, 0}, 0,
FILE_OPTIONS_STRING}
--- 1.53/sql/sql_trigger.cc 2006-10-18 15:28:25 +04:00
+++ 1.54/sql/sql_trigger.cc 2006-10-18 15:28:25 +04:00
@@ -27,6 +27,18 @@
const char * const triggers_file_ext= ".TRG";
/*
+ Since Table_triggers_list is non-POD type offsetof() macro can't be used
+ with it according to the current version of C++ standard (attempt to do
+ this will produce warnings). So we use auxillary object to get offsets
+ of Table_triggers_list's members (we assume that all objects of this
+ type have same offsets of its members).
+ This is temporary hack which should be removed once we will refactor
+ File_parser code.
+*/
+
+static Table_triggers_list dummy(0);
+
+/*
Table of .TRG file field descriptors.
We have here only one field now because in nearest future .TRG
files will be merged into .FRM files (so we don't need something
@@ -36,17 +48,17 @@
{
{
{(char *) STRING_WITH_LEN("triggers") },
- offsetof(class Table_triggers_list, definitions_list),
+ offsetof_in_object(dummy, definitions_list),
FILE_OPTIONS_STRLIST
},
{
{(char *) STRING_WITH_LEN("sql_modes") },
- offsetof(class Table_triggers_list, definition_modes_list),
+ offsetof_in_object(dummy, definition_modes_list),
FILE_OPTIONS_ULLLIST
},
{
{(char *) STRING_WITH_LEN("definers") },
- offsetof(class Table_triggers_list, definers_list),
+ offsetof_in_object(dummy, definers_list),
FILE_OPTIONS_STRLIST
},
{ { 0, 0 }, 0, FILE_OPTIONS_STRING }
@@ -55,7 +67,7 @@
File_option sql_modes_parameters=
{
{(char*) STRING_WITH_LEN("sql_modes") },
- offsetof(class Table_triggers_list, definition_modes_list),
+ offsetof_in_object(dummy, definition_modes_list),
FILE_OPTIONS_ULLLIST
};
| Thread |
|---|
| • bk commit into 5.0 tree (dlenev:1.2238) BUG#15228 | dlenev | 18 Oct |