oqgraph-dev team mailing list archive
-
oqgraph-dev team
-
Mailing list archive
-
Message #00071
Patches to fix crashes
Hiya
the first patch checks the attributes are present as expected without crashing
the daemon. I have tried to be consistent with the error messages.
the second patch fixes an assertion that occurred with DEBUG enabled where the
length of the table was off by one for some reason
I probably need to work out how to push this back to launchpad, I think you
mentioned it in an earlier email
--Andrew
--
https://launchpad.net/~andymc73
http://blog.oldcomputerjunk.net
Twitter: @andymc73
GPG: http://www.andrewmcdonnell.net/gpg.html
=== modified file 'storage/oqgraph/ha_oqgraph.cc'
--- old/storage/oqgraph/ha_oqgraph.cc 2013-02-21 18:36:25 +0000
+++ new/storage/oqgraph/ha_oqgraph.cc 2013-02-26 10:24:14 +0000
@@ -43,11 +43,12 @@
#include "unireg.h"
#include "sql_class.h"
+#include "my_dbug.h"
+
#define OQGRAPH_STATS_UPDATE_THRESHOLD 10
using namespace open_query;
-
struct oqgraph_table_option_struct
{
char *table_name;
@@ -114,6 +115,7 @@
static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table,
MEM_ROOT *mem_root)
{
+ DBUG_PRINT( "oq-debug", ("oqgraph_create_handler"));
return new (mem_root) ha_oqgraph(hton, table);
}
@@ -127,6 +129,9 @@
return 1;
#endif
+ DBUG_PRINT( "oq-debug", ("oqgraph_init"));
+
+
#if MYSQL_VERSION_ID >= 50100
hton->state= SHOW_OPTION_YES;
hton->db_type= DB_TYPE_AUTOASSIGN;
@@ -139,6 +144,7 @@
static int oqgraph_fini(void *)
{
+ DBUG_PRINT( "oq-debug", ("oqgraph_fini"));
oqgraph_init_done= FALSE;
#endif
return 0;
@@ -317,10 +323,33 @@
int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
{
+ DBUG_PRINT( "oq-debug", ("open(name=%s,mode=%d)", name, mode));
+
THD* thd = current_thd;
oqgraph_table_option_struct *options=
reinterpret_cast<oqgraph_table_option_struct*>(table->s->option_struct);
+ // Catch cases where table was not constructed properly
+ if (!options) {
+ fprint_error("Invalid oqgraph backing store (null attributes)");
+ return -1;
+ }
+ if (!options->table_name) {
+ fprint_error("Invalid oqgraph backing store (unspecified data_table attribute)");
+ // if table_name if present but doesnt actually exist, we will fail out below
+ // when we call open_table_def(). same probably applies for the id fields
+ return -1;
+ }
+ if (!options->origid) {
+ fprint_error("Invalid oqgraph backing store (unspecified origid attribute)");
+ return -1;
+ }
+ if (!options->destid) {
+ fprint_error("Invalid oqgraph backing store (unspecified destid attribute)");
+ return -1;
+ }
+ // weight is optional
+
error_message.length(0);
const char* p= strend(name)-1;
=== modified file 'storage/oqgraph/ha_oqgraph.cc'
--- old/storage/oqgraph/ha_oqgraph.cc 2013-02-21 18:36:25 +0000
+++ new/storage/oqgraph/ha_oqgraph.cc 2013-02-26 10:24:14 +0000
@@ -332,18 +361,20 @@
options->table_name, "");
size_t tlen= strlen(options->table_name);
- size_t plen= (int)(p - name) + tlen;
+ size_t plen= (int)(p - name) + tlen + 1;
share->path.str= (char*)
- alloc_root(&share->mem_root, plen + 1);
+ alloc_root(&share->mem_root, plen);
strmov(strnmov(share->path.str, name, (int)(p - name) + 1), options->table_name);
share->normalized_path.str= share->path.str;
share->path.length= share->normalized_path.length= plen;
origid= destid= weight= 0;
+ DBUG_PRINT( "oq-debug", ("share:(normalized_path=%s,path.length=%zu)",
+ share->normalized_path.str, share->path.length));
while (open_table_def(thd, share, 0))
{
if (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE)
@@ -815,6 +846,9 @@
oqgraph_table_option_struct *options=
reinterpret_cast<oqgraph_table_option_struct*>(table_arg->s->option_struct);
+ DBUG_PRINT( "oq-debug", ("create(name=%s)", name));
+
+
if (int res = oqgraph_check_table_structure(table_arg))
return error_code(res);
Follow ups
References