[MDEV-8210] SELECT ... INTO OUTFILE [LOCAL] '...' Created: 2015-05-22  Updated: 2021-02-18

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Mikhail Gavrilov Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: None


 Description   

MySQL and MariaDB have very useful feature for loading big data arrays
LOAD DATA [LOCAL] which allow application server easily update big dictionaries.

But I don't understand why this feature absent in SELECT ... INTO OUTFILE statement.
It would be very useful for uploading big dictionaries into file.

Can you add [LOCAL] to SELECT ... INTO OUTFILE statement, please?



 Comments   
Comment by Mikhail Gavrilov [ 2015-05-22 ]

This also needed for resolving security issues. Because application works under one user, and SQL server run under another user. All data which exported with 'SELECT ... INTO OUTFILE' statement is inaccessible for application user and necessary invent a terrible perversion to get around this.

Comment by Antonio Fernandes [ 2016-01-14 ]

This is a very very nice feature that could be handled by client side. The CLI could, as the server does, write the file to the local filesystem.

Best regards,
Antonio Fernandes

Comment by Richard Bensley [ 2016-10-13 ]

I currently do this with a stored procedure on the server which I want to export data from. But I cannot manage an outfile on a remove server, unless I select into a inward CSV CONNECT engine table.

Comment by Daniel Black [ 2021-02-18 ]

An application in a `SELECT` statement (not OUTFILE) retrieves a structured set of data and hooking this to output cvs locally is fairly trivial (I'm sure it been implemented many times already).

A cli tool side could look like:

  mysql --skip-column-names  -Be 'select 1 as one,2 as two,3 as three' | tr '\t' ',' > file.csv

I certainly see a case for scripting this as the disconnect between mysql protocol field separation and scripted output isn't a perfect match.

Extending the mysql/mariadb client to take the terminated/enclosed/escaped options line the `SELECT INTO OUTFILE` might be the easier way to get this implemented. Patches welcome.

Generated at Thu Feb 08 07:25:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.