Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-22306

Support for LOAD DATA FROM/INTO STREAM

    XMLWordPrintable

Details

    Description

      Since enabling local_imfile is considered to be unsecure (and disabled in recent versions), implement a new command
      LOAD DATA FROM/TO STREAM.

      Syntax:

      1. FROM STREAM

      LOAD DATA [LOW_PRIORITY | CONCURRENT] FROM STREAM
          [REPLACE | IGNORE]
          INTO TABLE tbl_name
          [CHARACTER SET charset_name]
          [{FIELDS | COLUMNS}
              [TERMINATED BY 'string']
              [[OPTIONALLY] ENCLOSED BY 'char']
              [ESCAPED BY 'char']
          ]
          [LINES
              [STARTING BY 'string']
              [TERMINATED BY 'string']
          ]
          [IGNORE number LINES]
          [(col_name_or_user_var,...)]
          [SET col_name = expr,...]
      

      2. TO STREAM

      LOAD DATA INTO STREAM
              [CHARACTER SET charset_name]
              [export_options]
      SELECT ....
       
      export_options:
          [{FIELDS | COLUMNS}
              [TERMINATED BY 'string']
              [[OPTIONALLY] ENCLOSED BY 'char']
              [ESCAPED BY 'char']
          ]
          [LINES
              [STARTING BY 'string']
              [TERMINATED BY 'string']
          ]
      
      

      3. Client implementation

      New options:

      MARIADB_OPT_STREAM_IN
      MARIADB_OPT_STREAM_OUT

      Example for registering a stream:

      FILE *fp_in= fopen("./foo.csv", "r");
       
      rc= mysql_options(mysql, MARIADB_OPT_STREAM_IN, fp_in);
      check_mysql_rc(rc, mysql);
       
      rc= mysql_query("LOAD DATA FROM STREAM INTO TABLE t1 FIELDS TERMINATED BY ',', 
      check_mysql_rc(rc, mysql);
       
      /* tbd: should Connector/C close the stream or should it be handled by application?! */
      
      

      4. Protocol implementation (tbd)

      Server response package:
      0xFB 0x00 0x01 for FROM STREAM
      0xFB 0x00 0x02 for INTO_STREAM

      Attachments

        Activity

          People

            serg Sergei Golubchik
            georg Georg Richter
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.