Fixed MYSQL_OPT_RECONNECT option.
authorJiří Filipovič <fila@ics.muni.cz>
Thu, 13 Dec 2007 11:48:45 +0000 (11:48 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Thu, 13 Dec 2007 11:48:45 +0000 (11:48 +0000)
org.glite.jp.primary/src/mysql.c

index 82e5747..fe45558 100644 (file)
@@ -58,9 +58,10 @@ int glite_jp_db_connect(glite_jp_context_t ctx,char *cs)
        }
 
        mysql_options(ctx->dbhandle, MYSQL_READ_DEFAULT_FILE, "my");
-#ifdef MYSQL_OPT_RECONNECT
-       mysql_options(ctx->dbhandle, MYSQL_OPT_RECONNECT, &reconnect);
-#endif
+       if (MYSQL_VERSION_ID >= 50013){
+               mysql_options(ctx->dbhandle, MYSQL_OPT_RECONNECT, &reconnect);
+               printf("Set MYSQL_OPT_RECONNECT\n");
+       }
 
        host = user = pw = db = NULL;
 
@@ -124,6 +125,7 @@ int glite_jp_db_execstmt(glite_jp_context_t ctx,char *txt,glite_jp_db_stmt_t *st
                                        err.code = EEXIST;
                                        err.desc = mysql_error((MYSQL *) ctx->dbhandle);
                                        glite_jp_stack_error(ctx,&err);
+                                       printf("glite_jp_db_execstmt return from 127, ctx->error = %i\n", ctx->error);
                                        return -1;
                                        break;
                                case CR_SERVER_GONE_ERROR:
@@ -133,6 +135,7 @@ int glite_jp_db_execstmt(glite_jp_context_t ctx,char *txt,glite_jp_db_stmt_t *st
                                        break;
                                default:
                                        my_err(ctx, __FUNCTION__);
+                                       printf("glite_jp_db_execstmt return from 137, ctx->error = %i\n", ctx->error);
                                        return -1;
                                        break;
                        }
@@ -145,6 +148,7 @@ int glite_jp_db_execstmt(glite_jp_context_t ctx,char *txt,glite_jp_db_stmt_t *st
                if (!*stmt) {
                        err.code = ENOMEM;
                        glite_jp_stack_error(ctx,&err);
+                       printf("glite_jp_db_execstmt return from 150, ctx->error = %i\n", ctx->error);
                        return -1;
                }
                memset(*stmt,0,sizeof(**stmt));
@@ -153,6 +157,7 @@ int glite_jp_db_execstmt(glite_jp_context_t ctx,char *txt,glite_jp_db_stmt_t *st
                if (!(**stmt).result) {
                        if (mysql_errno((MYSQL *) ctx->dbhandle)) {
                                my_err(ctx, __FUNCTION__);
+                               printf("glite_jp_db_execstmt return from 159, ctx->error = %i\n", ctx->error);
                                return -1;
                        }
                }
@@ -161,6 +166,7 @@ int glite_jp_db_execstmt(glite_jp_context_t ctx,char *txt,glite_jp_db_stmt_t *st
                mysql_free_result(r);
        }
        
+       printf("glite_jp_db_execstmt return from 168, ctx->error = %i\n", ctx->error);
        return mysql_affected_rows((MYSQL *) ctx->dbhandle);
 }