~stewart/dbd-drizzle/fixup-for-modern-perl

« back to all changes in this revision

Viewing changes to dbdimp.c

  • Committer: Patrick Galbraith
  • Date: 2010-10-19 08:31:06 UTC
  • Revision ID: patg@patg-desktop-20101019083106-zdxdybpyqi8imr7v
Version .301 to be released. Added Eric's patch plus work on column_info

Show diffs side-by-side

added added

removed removed

Lines of Context:
2048
2048
                                                imp_sth->unbuffered_result
2049
2049
                                               );
2050
2050
 
2051
 
  uint16_t colcount = 0;
 
2051
  colcount = 0;
2052
2052
  if (imp_sth->result != NULL)
2053
2053
  {
2054
2054
    colcount = drizzle_result_column_count(imp_sth->result);
2077
2077
      PerlIO_printf doesn't always handle imp_sth->row_num %llu 
2078
2078
      consistantly!!
2079
2079
    */
2080
 
    sprintf(actual_row_num, "%l", imp_sth->row_num);
 
2080
    sprintf(actual_row_num, "%l", (long int) imp_sth->row_num);
2081
2081
    PerlIO_printf(DBILOGFP,
2082
2082
                  " <- dbd_st_execute returning imp_sth->row_num %s\n",
2083
2083
                  actual_row_num);
3167
3167
 
3168
3168
  return 0;
3169
3169
}
 
3170
 
 
3171
static int run_query(drizzle_con_st *con, drizzle_result_st *result,
 
3172
                     const char *query, int len)
 
3173
{
 
3174
  drizzle_return_t ret;
 
3175
  drizzle_result_st result_buffer;
 
3176
 
 
3177
  if (result == NULL)
 
3178
    result= &result_buffer;
 
3179
 
 
3180
  result= drizzle_query(con, result, query, len, &ret);
 
3181
 
 
3182
  if (ret == DRIZZLE_RETURN_OK)
 
3183
    ret= drizzle_result_buffer(result);
 
3184
 
 
3185
  if (result == &result_buffer)
 
3186
    drizzle_result_free(result);
 
3187
 
 
3188
  return ret;
 
3189
}
 
3190
static int drop_schema(imp_dbh_t *imp_dbh, const char *schema)
 
3191
{
 
3192
  char query[200];
 
3193
 
 
3194
  sprintf(query, "DROP DATABASE %s", schema);
 
3195
  if (run_query(imp_dbh->con, NULL, query, strlen(query)))
 
3196
  {
 
3197
    do_error(imp_dbh, drizzle_con_errno(imp_dbh->con),
 
3198
             drizzle_con_error(imp_dbh->con),
 
3199
             drizzle_con_sqlstate(imp_dbh->con));
 
3200
    return 1;
 
3201
  }
 
3202
  return 0;
 
3203
}
 
3204
 
 
3205
static int create_schema(imp_dbh_t *imp_dbh, const char *schema)
 
3206
{
 
3207
  char query[200];
 
3208
 
 
3209
  sprintf(query, "CREATE DATABASE %s", schema);
 
3210
 
 
3211
  if (run_query(imp_dbh->con, NULL, query, strlen(query)))
 
3212
  {
 
3213
    do_error(imp_dbh, drizzle_con_errno(imp_dbh->con),
 
3214
             drizzle_con_error(imp_dbh->con),
 
3215
             drizzle_con_sqlstate(imp_dbh->con));
 
3216
    return 1;
 
3217
  }
 
3218
 
 
3219
}