Branch: Tag:

2015-06-09

2015-06-09 09:12:33 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Mysql: Reduced cross-cmod dependencies.

The mysql program now nolonger needs to know the internals of
the mysql_result program.

Also some related name-space cleanups.

96:   /* Local includes */   #include "precompiled_mysql.h"    - /* NOTE: Same as the CVARs in result.cmod! */ - struct precompiled_mysql_result - { -  struct obejct *connection; -  MYSQL_RES *result; -  int eof; -  int typed_mode; - }; -  +    /*    * Globals    */
167:   #define MYSQL_DISALLOW()   #endif /* _REENTRANT */    - #define PIKE_MYSQL_FLAG_STORE_RESULT 1 - #define PIKE_MYSQL_FLAG_TYPED_RESULT 2 -  +    #define CHECK_8BIT_NONBINARY_STRING(FUNC, ARG) do { \    if (TYPEOF(sp[ARG-1-args]) != T_STRING || \    sp[ARG-1-args].u.string->size_shift || \
1185:    push_int(0);    } else {    /* Return the result-object */ -  struct precompiled_mysql_result *res; -  struct object *o; -  -  /* Create the object */ -  ref_push_object(Pike_fp->current_object); -  if (flags & PIKE_MYSQL_FLAG_TYPED_RESULT) { -  push_int(1); -  push_object(o = clone_object(Mysql_mysql_result_program, 2)); -  } else { -  push_object(o = clone_object(Mysql_mysql_result_program, 1)); +  push_object(make_mysql_result(Pike_fp->current_object, result, flags));    } -  -  /* Set the result. */ -  if ((!(res = get_storage(o, Mysql_mysql_result_program))) || -  res->result) { -  mysql_free_result(result); -  Pike_error("%s(): Bad mysql result object!\n", name); +    } -  res->result = result; -  } - } +       PIKEFUN object big_query(string query)   {
1563:       pop_n_elems(args);    -  { +     /* Return the result-object */ -  struct precompiled_mysql_result *res; -  struct object *o; -  -  /* Create the object */ -  ref_push_object(Pike_fp->current_object); -  push_object(o = clone_object(Mysql_mysql_result_program, 1)); -  -  /* Set the result. */ -  if ((!(res = get_storage(o, Mysql_mysql_result_program))) || -  res->result) { -  mysql_free_result(result); -  Pike_error("Mysql.mysql->list_dbs(): Bad mysql result object!\n"); +  push_object(make_mysql_result(Pike_fp->current_object, result, 0));   } -  res->result = result; -  } - } +       /*! @decl object(Mysql.mysql_result) list_tables()    *! @decl object(Mysql.mysql_result) list_tables(string wild)
1635:       pop_n_elems(args);    -  { +     /* Return the result-object */ -  struct precompiled_mysql_result *res; -  struct object *o; -  -  /* Create the object */ -  ref_push_object(Pike_fp->current_object); -  push_object(o = clone_object(Mysql_mysql_result_program, 1)); -  -  /* Set the result. */ -  if ((!(res = get_storage(o, Mysql_mysql_result_program))) || -  res->result) { -  mysql_free_result(result); -  Pike_error("Mysql.mysql->list_tables(): Bad mysql result object!\n"); +  push_object(make_mysql_result(Pike_fp->current_object, result, 0));   } -  res->result = result; -  } - } +       /*! @decl array(int|mapping(string:mixed)) list_fields(string table)    *! @decl array(int|mapping(string:mixed)) list_fields(string table, @
1831:    Pike_error("Mysql.mysql->list_processes(): Cannot list processes: %s\n", err);    }    -  { +     /* Return the result-object */ -  struct precompiled_mysql_result *res; -  struct object *o; -  -  /* Create the object */ -  ref_push_object(Pike_fp->current_object); -  push_object(o = clone_object(Mysql_mysql_result_program, 1)); -  -  /* Set the result. */ -  if ((!(res = get_storage(o, Mysql_mysql_result_program))) || -  res->result) { -  mysql_free_result(result); -  Pike_error("Mysql.mysql->list_processes(): Bad mysql result object!\n"); +  push_object(make_mysql_result(Pike_fp->current_object, result, 0));   } -  res->result = result; -  } - } +       /*! @decl int binary_data()    *!