From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | proposal: psql \setfileref |
Date: | 2016-08-31 15:32:42 |
Message-ID: | CAFj8pRB2pAyds2+PUvUpdc7DRK=cxDH=SUY7PV0gvQbbw9nLMg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi
I propose a new type of psql variables - file references. The content of
file reference is specified by referenced file. It allows simple inserting
large data without necessity of manual escaping or using LO api.
When I wrote the patch, I used parametrized queries for these data instead
escaped strings - the code is not much bigger, and the error messages are
much more friendly if query is not bloated by bigger content. The text mode
is used only - when escaping is not required, then content is implicitly
transformed to bytea. By default the content of file is bytea. When use
requires escaping, then he enforces text escaping - because it has sense
only for text type.
postgres=# \setfileref a ~/test2.xml
postgres=# \setfileref b ~/avatar.gif
postgres=# insert into test values(convert_from(:a, 'latin2')::xml, :b); --
xml is passed as bytea
postgres=# insert into test values(:'a', :b); -- xml is passed via unknown
text value
The content of file reference variables is not persistent in memory.
Comments, notes?
Regards
Pavel
Attachment | Content-Type | Size |
---|---|---|
psql-setfileref-initial.patch | text/x-patch | 11.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2016-08-31 15:41:53 | Re: pg_sequence catalog |
Previous Message | Tom Lane | 2016-08-31 15:23:27 | Re: pg_sequence catalog |