WL#13926: Periodic synchronization with storage device for select into outfile/dumpfile controlled by system variables

Affects: Server-8.0   —   Status: Complete

WL implements periodic synchronization with storage device
for select into outfile/dumfile controlled by system variables.
Based on the contribution provided by Facebook.
(See http://bugs.mysql.com/bug.php?id=96799).
F1 Variable select_into_buffer_size value is between 8192 and 2147479552.
Default value is 131072.

F2 Variable select_into_disk_sync has values OFF|ON.
Default value is OFF.

F3 Variable select_into_disk_sync_delay is between 0 and 31536000.
Default value is 0.

F4 Disk synchronization is preformed if select_into_disk_sync
variable is ON.

F5 Delay after buffer sync is performed only if select_into_disk_sync variable
is ON and select_into_disk_sync_delay value is not 0.
  Added system variables:

 1. select_into_buffer_size        Buffer size for SELECT INTO OUTFILE/DUMPFILE.


    Property 	          Value
    Command-Line Format  --select-into-buffer-size=#
    System Variable      select_into_buffer_size
    Scope                Global, Session
    Dynamic              Yes
    SET_VAR Hint Applies Yes
    Type 	         Integer
    Default Value 	 131072
    Minimum Value 	 8192
    Maximum Value 	 2147479552

    Variable sets buffer size(in bytes) which is used for
    OUTFILE/DUMPFILE export file. Before the WL value of
    'read-buffer-size' system variable was used for the
    buffer size. Default/min/max values are the same for
    select-into-buffer-size and read-buffer-size variables.
 

 2. select_into_disk_sync          Synchronize flushed buffer with disk for
                                   SELECT INTO OUTFILE/DUMPFILE.

    Property             Value
    Command-Line Format  --select-into-disk-sync[={OFF|ON}]
    System Variable      select_into_disk_sync
    Scope                Global, Session
    Dynamic              Yes
    SET_VAR Hint Applies Yes
    Type                 Boolean
    Default Value        OFF

    If enabled, synchronize data with storage device after flushing
    the buffer for OUTFILE/DUMPFILE export file. No synchronization 
    if the variable is OFF(current behavior).
    

 3. select_into_disk_sync_delay    The delay in milliseconds after each
                                   buffer sync for SELECT INTO OUTFILE/DUMPFILE.        
                                   Requires select_into_sync_disk = ON.

    Property             Value
    Command-Line Format  --select-into-disk-sync-delay=#
    System Variable 	 select_into_disk_sync_delay
    Scope                Global, Session
    Dynamic              Yes
    SET_VAR Hint Applies Yes
    Type                 Integer
    Default Value        0
    Minimum Value        0
    Maximum Value        31536000


 Added system variables:

  static Sys_var_ulong Sys_select_into_buffer_size(
    "select_into_buffer_size", "Buffer size for SELECT INTO OUTFILE/DUMPFILE.",
    HINT_UPDATEABLE SESSION_VAR(select_into_buffer_size), CMD_LINE(OPT_ARG),
    VALID_RANGE(IO_SIZE * 2, INT_MAX32), DEFAULT(128 * 1024),
    BLOCK_SIZE(IO_SIZE));

  static Sys_var_bool Sys_select_into_disk_sync(
    "select_into_disk_sync",
    "Synchronize flushed buffer with disk for SELECT INTO OUTFILE/DUMPFILE.",
    HINT_UPDATEABLE SESSION_VAR(select_into_disk_sync), CMD_LINE(OPT_ARG),
    DEFAULT(false));

  static Sys_var_uint Sys_select_into_disk_sync_delay(
    "select_into_disk_sync_delay",
    "The delay in milliseconds after each buffer sync "
    "for SELECT INTO OUTFILE/DUMPFILE. Requires select_into_sync_disk = ON.",
    HINT_UPDATEABLE SESSION_VAR(select_into_disk_sync_delay), CMD_LINE(OPT_ARG),
    VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(0), BLOCK_SIZE(1));



 Added fields into IO_CACHE struct

    bool disk_sync{false};        // Synchronize flushed buffer with disk.
    uint disk_sync_delay{0};      // Delay after disk synchronization of the
                                  // flushed buffer. Requirew disk_sync = true.

  Function my_b_flush_io_cache() is modified so that
  it performs synchronization with storage device after buffer flushing
  if 'select_into_disk_sync' variable is set ON and optionally delay
  after synchronization if 'select_into_disk_sync_delay' variable
  is non-zero.

  Function query_result.cc, create_file() is modified to
  use 'select_into_buffer_size' value for the buffer size for
  'select into' command. Variables IO_CACHE::disk_sync,
  IO_CACHE::disc_sync_delay fields are set to
  the system variable values(select_into_disk_sync,
  select_into_disk_sync_delay).