List:Commits« Previous MessageNext Message »
From:Rafal Somla Date:September 8 2009 9:43am
Subject:bzr commit into mysql-6.0-backup branch (Rafal.Somla:2869) Bug#40587
View as plain text  
#At file:///ext/mysql/bzr/backup/stream-doc/ based on revid:rafal.somla@stripped

 2869 Rafal Somla	2009-09-08
      Followup patch for BUG#40587. It moves definitions of functions
      bstream_{rd,wr}_summary(), bstream_{rd,wr}_binlog_pos() and 
      bstream_{rd,wr}_item_pos() in backup/stream_v1.c so that they 
      are defined at the place where the format of the corresponding
      part of backup image is documented. This is so that it is easy 
      to verify that functions correctly implement the described format.

    modified:
      sql/backup/stream_v1.c
=== modified file 'sql/backup/stream_v1.c'
--- a/sql/backup/stream_v1.c	2009-09-08 09:29:08 +0000
+++ b/sql/backup/stream_v1.c	2009-09-08 09:43:04 +0000
@@ -283,104 +283,6 @@ int bstream_rd_preamble(backup_stream *s
 }
 
 
-/** 
-  Save binlog position. 
-
-  @see @ref summary.
-*/
-int bstream_wr_binlog_pos(backup_stream *s, struct st_bstream_binlog_info pos)
-{
-  blob name;
-  int ret= BSTREAM_OK;
-
-  name.begin= (byte *)pos.file;
-  name.end= name.begin + (pos.file ? strlen(pos.file) : 0);
-  CHECK_WR_RES(bstream_wr_int4(s,pos.pos));
-  CHECK_WR_RES(bstream_wr_string(s,name));
-
-  wr_error:
-
-  return ret;
-}
-
-/**
-  Read binlog position.
-
-  @retval BSTREAM_ERROR  Error while reading
-  @retval BSTREAM_OK     Read successful
-  @retval BSTREAM_EOC    Read successful and end of chunk has been reached
-  @retval BSTREAM_EOS    Read successful and end of stream has been reached
-
-  @see @ref summary.
-*/
-int bstream_rd_binlog_pos(backup_stream *s, struct st_bstream_binlog_info *pos)
-{
-  blob name= {NULL, NULL};
-  int ret= BSTREAM_OK;
-
-  CHECK_RD_OK(bstream_rd_int4(s,&pos->pos));
-  CHECK_RD_RES(bstream_rd_string(s,&name));
-
-  if (ret != BSTREAM_ERROR)
-    pos->file= (char*)name.begin;
-
-  rd_error:
-
-  return ret;
-}
-
-/**
-  Write backup image summary.
-
-  This function assumes that all members of the header (such as @c vp_time) are
-  already filled. It also stores the 0x00 byte separating summary from the
-  preceding table data chunks.
-
-  @see @ref summary
-*/
-int bstream_wr_summary(backup_stream *s, struct st_bstream_image_header *hdr)
-{
-  int ret= BSTREAM_OK;
-
-  CHECK_WR_RES(bstream_wr_byte(s,0x00));
-  CHECK_WR_RES(bstream_wr_time(s,&hdr->vp_time));
-  CHECK_WR_RES(bstream_wr_time(s,&hdr->end_time));
-  CHECK_WR_RES(bstream_wr_binlog_pos(s,hdr->binlog_info));
-  CHECK_WR_RES(bstream_wr_binlog_pos(s,hdr->binlog_group));
-
-  wr_error:
-
-  return ret;
-}
-
-/**
-  Read backup image summary
-
-  The information stored in the summary section is read and stored in the image
-  header structure.
-
-  @retval BSTREAM_ERROR  Error while reading
-  @retval BSTREAM_OK     Read successful
-  @retval BSTREAM_EOC    Read successful and end of chunk has been reached
-  @retval BSTREAM_EOS    Read successful and end of stream has been reached
-
-  @see @ref summary
-*/
-int bstream_rd_summary(backup_stream *s, struct st_bstream_image_header *hdr)
-{
-  int ret= BSTREAM_OK;
-
-  CHECK_RD_OK(bstream_rd_time(s,&hdr->vp_time));
-  CHECK_RD_OK(bstream_rd_time(s,&hdr->end_time));
-  CHECK_RD_OK(bstream_rd_binlog_pos(s,&hdr->binlog_info));
-  CHECK_RD_RES(bstream_rd_binlog_pos(s,&hdr->binlog_group));
-
-  rd_error:
-
-  return ret;
-}
-
-
 /*************************************************************************
  *
  *   IMAGE HEADER
@@ -1030,73 +932,6 @@ int bstream_rd_catalogue(backup_stream *
   return ret;
 }
 
-
-/**
-  Save object type.
-
-  See @ref basic_data_itype for encoding of object types.
-
-  @retval BSTREAM_OK   type was saved successfully
-  @retval BSTREAM_ERROR error writing or attempt to save unknown type.
-*/
-int bstream_wr_item_type(backup_stream *s, enum enum_bstream_item_type type)
-{
-  switch (type) {
-  case BSTREAM_IT_CHARSET:   return bstream_wr_int2(s,1);
-  case BSTREAM_IT_USER:      return bstream_wr_int2(s,2);
-  case BSTREAM_IT_PRIVILEGE: return bstream_wr_int2(s,3);
-  case BSTREAM_IT_DB:        return bstream_wr_int2(s,4);
-  case BSTREAM_IT_TABLE:     return bstream_wr_int2(s,5);
-  case BSTREAM_IT_VIEW:      return bstream_wr_int2(s,6);
-  case BSTREAM_IT_SPROC:     return bstream_wr_int2(s,7);
-  case BSTREAM_IT_SFUNC:     return bstream_wr_int2(s,8);
-  case BSTREAM_IT_EVENT:     return bstream_wr_int2(s,9);
-  case BSTREAM_IT_TRIGGER:   return bstream_wr_int2(s,10);
-  case BSTREAM_IT_TABLESPACE: return bstream_wr_int2(s,11);
-  case BSTREAM_IT_LAST:      return bstream_wr_int2(s,0);
-  default: return BSTREAM_ERROR;
-  }
-}
-
-/**
-  Read object type.
-
-  See @ref basic_data_itype for encoding of object types.
-
-  @retval BSTREAM_ERROR  Error while reading or non-recognized type found.
-  @retval BSTREAM_OK     Read successful
-  @retval BSTREAM_EOC    Read successful and end of chunk has been reached
-  @retval BSTREAM_EOS    Read successful and end of stream has been reached
-*/
-int bstream_rd_item_type(backup_stream *s, enum enum_bstream_item_type *type)
-{
-  int ret;
-  unsigned int x;
-
-  ret= bstream_rd_int2(s,&x);
-
-  if (ret == BSTREAM_ERROR)
-    return BSTREAM_ERROR;
-
-  switch (x) {
-  case 0: *type= BSTREAM_IT_LAST; break;
-  case 1: *type= BSTREAM_IT_CHARSET; break;
-  case 2: *type= BSTREAM_IT_USER; break;
-  case 3: *type= BSTREAM_IT_PRIVILEGE; break;
-  case 4: *type= BSTREAM_IT_DB; break;
-  case 5: *type= BSTREAM_IT_TABLE; break;
-  case 6: *type= BSTREAM_IT_VIEW; break;
-  case 7: *type= BSTREAM_IT_SPROC; break;
-  case 8: *type= BSTREAM_IT_SFUNC; break;
-  case 9: *type= BSTREAM_IT_EVENT; break;
-  case 10: *type= BSTREAM_IT_TRIGGER; break;
-  case 11: *type= BSTREAM_IT_TABLESPACE; break;
-  default: return BSTREAM_ERROR;
-  }
-
-  return ret;
-}
-
 /**
   @page image_layer
 
@@ -1149,6 +984,9 @@ int bstream_rd_item_type(backup_stream *
   Allowable object type values are given in @ref basic_data_itype.
 */
 
+int bstream_wr_item_type(backup_stream *s, enum enum_bstream_item_type type);
+int bstream_rd_item_type(backup_stream *s, enum enum_bstream_item_type *type);
+
 /** 
   Save catalogue of objects belonging to given database. 
 
@@ -2172,6 +2010,105 @@ int bstream_rd_data_chunk(backup_stream 
 */
 
 
+/** 
+  Save binlog position. 
+
+  @see @ref summary.
+*/
+int bstream_wr_binlog_pos(backup_stream *s, struct st_bstream_binlog_info pos)
+{
+  blob name;
+  int ret= BSTREAM_OK;
+
+  name.begin= (byte *)pos.file;
+  name.end= name.begin + (pos.file ? strlen(pos.file) : 0);
+  CHECK_WR_RES(bstream_wr_int4(s,pos.pos));
+  CHECK_WR_RES(bstream_wr_string(s,name));
+
+  wr_error:
+
+  return ret;
+}
+
+/**
+  Read binlog position.
+
+  @retval BSTREAM_ERROR  Error while reading
+  @retval BSTREAM_OK     Read successful
+  @retval BSTREAM_EOC    Read successful and end of chunk has been reached
+  @retval BSTREAM_EOS    Read successful and end of stream has been reached
+
+  @see @ref summary.
+*/
+int bstream_rd_binlog_pos(backup_stream *s, struct st_bstream_binlog_info *pos)
+{
+  blob name= {NULL, NULL};
+  int ret= BSTREAM_OK;
+
+  CHECK_RD_OK(bstream_rd_int4(s,&pos->pos));
+  CHECK_RD_RES(bstream_rd_string(s,&name));
+
+  if (ret != BSTREAM_ERROR)
+    pos->file= (char*)name.begin;
+
+  rd_error:
+
+  return ret;
+}
+
+
+/**
+  Write backup image summary.
+
+  This function assumes that all members of the header (such as @c vp_time) are
+  already filled. It also stores the 0x00 byte separating summary from the
+  preceding table data chunks.
+
+  @see @ref summary
+*/
+int bstream_wr_summary(backup_stream *s, struct st_bstream_image_header *hdr)
+{
+  int ret= BSTREAM_OK;
+
+  CHECK_WR_RES(bstream_wr_byte(s,0x00));
+  CHECK_WR_RES(bstream_wr_time(s,&hdr->vp_time));
+  CHECK_WR_RES(bstream_wr_time(s,&hdr->end_time));
+  CHECK_WR_RES(bstream_wr_binlog_pos(s,hdr->binlog_info));
+  CHECK_WR_RES(bstream_wr_binlog_pos(s,hdr->binlog_group));
+
+  wr_error:
+
+  return ret;
+}
+
+/**
+  Read backup image summary
+
+  The information stored in the summary section is read and stored in the image
+  header structure.
+
+  @retval BSTREAM_ERROR  Error while reading
+  @retval BSTREAM_OK     Read successful
+  @retval BSTREAM_EOC    Read successful and end of chunk has been reached
+  @retval BSTREAM_EOS    Read successful and end of stream has been reached
+
+  @see @ref summary
+*/
+int bstream_rd_summary(backup_stream *s, struct st_bstream_image_header *hdr)
+{
+  int ret= BSTREAM_OK;
+
+  CHECK_RD_OK(bstream_rd_time(s,&hdr->vp_time));
+  CHECK_RD_OK(bstream_rd_time(s,&hdr->end_time));
+  CHECK_RD_OK(bstream_rd_binlog_pos(s,&hdr->binlog_info));
+  CHECK_RD_RES(bstream_rd_binlog_pos(s,&hdr->binlog_group));
+
+  rd_error:
+
+  return ret;
+}
+
+
 /*********************************************************************
  *
  *   WRITING/READING BASIC TYPES
@@ -2586,4 +2523,71 @@ int bstream_rd_time(backup_stream *s, bs
    Object types are encoded using two bytes. A value of 0 is not a valid object 
    type, so a 0x00 0x00 sequence can be used to separate one object list from 
    the next.
-*/ 
+*/
+
+/**
+  Save object type.
+
+  See @ref basic_data_itype for encoding of object types.
+
+  @retval BSTREAM_OK   type was saved successfully
+  @retval BSTREAM_ERROR error writing or attempt to save unknown type.
+*/
+int bstream_wr_item_type(backup_stream *s, enum enum_bstream_item_type type)
+{
+  switch (type) {
+  case BSTREAM_IT_CHARSET:   return bstream_wr_int2(s,1);
+  case BSTREAM_IT_USER:      return bstream_wr_int2(s,2);
+  case BSTREAM_IT_PRIVILEGE: return bstream_wr_int2(s,3);
+  case BSTREAM_IT_DB:        return bstream_wr_int2(s,4);
+  case BSTREAM_IT_TABLE:     return bstream_wr_int2(s,5);
+  case BSTREAM_IT_VIEW:      return bstream_wr_int2(s,6);
+  case BSTREAM_IT_SPROC:     return bstream_wr_int2(s,7);
+  case BSTREAM_IT_SFUNC:     return bstream_wr_int2(s,8);
+  case BSTREAM_IT_EVENT:     return bstream_wr_int2(s,9);
+  case BSTREAM_IT_TRIGGER:   return bstream_wr_int2(s,10);
+  case BSTREAM_IT_TABLESPACE: return bstream_wr_int2(s,11);
+  case BSTREAM_IT_LAST:      return bstream_wr_int2(s,0);
+  default: return BSTREAM_ERROR;
+  }
+}
+
+/**
+  Read object type.
+
+  See @ref basic_data_itype for encoding of object types.
+
+  @retval BSTREAM_ERROR  Error while reading or non-recognized type found.
+  @retval BSTREAM_OK     Read successful
+  @retval BSTREAM_EOC    Read successful and end of chunk has been reached
+  @retval BSTREAM_EOS    Read successful and end of stream has been reached
+*/
+int bstream_rd_item_type(backup_stream *s, enum enum_bstream_item_type *type)
+{
+  int ret;
+  unsigned int x;
+
+  ret= bstream_rd_int2(s,&x);
+
+  if (ret == BSTREAM_ERROR)
+    return BSTREAM_ERROR;
+
+  switch (x) {
+  case 0: *type= BSTREAM_IT_LAST; break;
+  case 1: *type= BSTREAM_IT_CHARSET; break;
+  case 2: *type= BSTREAM_IT_USER; break;
+  case 3: *type= BSTREAM_IT_PRIVILEGE; break;
+  case 4: *type= BSTREAM_IT_DB; break;
+  case 5: *type= BSTREAM_IT_TABLE; break;
+  case 6: *type= BSTREAM_IT_VIEW; break;
+  case 7: *type= BSTREAM_IT_SPROC; break;
+  case 8: *type= BSTREAM_IT_SFUNC; break;
+  case 9: *type= BSTREAM_IT_EVENT; break;
+  case 10: *type= BSTREAM_IT_TRIGGER; break;
+  case 11: *type= BSTREAM_IT_TABLESPACE; break;
+  default: return BSTREAM_ERROR;
+  }
+
+  return ret;
+}
+


Attachment: [text/bzr-bundle] bzr/rafal.somla@sun.com-20090908094304-nkvqzgmj7b7tq4zw.bundle
Thread
bzr commit into mysql-6.0-backup branch (Rafal.Somla:2869) Bug#40587Rafal Somla8 Sep