Re: [HACKERS] proposal: psql \setfileref

2016-12-01 Thread Haribabu Kommi
On Fri, Nov 18, 2016 at 5:53 AM, Pavel Stehule wrote: > Hi > > 2016-11-17 12:00 GMT+01:00 Pavel Stehule : > >> >> Hi >> >> a independent implementation of parametrized queries can looks like >> attached patch: >> >> this code is simple without any unexpected behave. >> >> parameters are used when

Re: [HACKERS] proposal: psql \setfileref

2016-11-17 Thread Pavel Stehule
Hi 2016-11-17 12:00 GMT+01:00 Pavel Stehule : > > Hi > > a independent implementation of parametrized queries can looks like > attached patch: > > this code is simple without any unexpected behave. > > parameters are used when user doesn't require escaping and when > PARAMETRIZED_QUERIES variable

Re: [HACKERS] proposal: psql \setfileref

2016-11-17 Thread Pavel Stehule
Hi a independent implementation of parametrized queries can looks like attached patch: this code is simple without any unexpected behave. parameters are used when user doesn't require escaping and when PARAMETRIZED_QUERIES variable is on Regards Pavel diff --git a/src/bin/psql/common.c b/src/b

Re: [HACKERS] proposal: psql \setfileref

2016-11-16 Thread Pavel Stehule
2016-11-16 17:58 GMT+01:00 Tom Lane : > Pavel Stehule writes: > > The Daniel's proposal has important issues: > > > 1. you need to store and hold the content in memory > > 2. you cannot use tab complete - without it this feature lost a usability > > 3. you have to do two steps > > 4. Depends on o

Re: [HACKERS] proposal: psql \setfileref

2016-11-16 Thread Tom Lane
Pavel Stehule writes: > The Daniel's proposal has important issues: > 1. you need to store and hold the content in memory > 2. you cannot use tab complete - without it this feature lost a usability > 3. you have to do two steps > 4. Depends on o.s. I think you're putting *way* too much emphasis

Re: [HACKERS] proposal: psql \setfileref

2016-11-16 Thread Pavel Stehule
2016-11-16 16:59 GMT+01:00 Robert Haas : > On Tue, Nov 15, 2016 at 11:48 AM, Pavel Stehule > wrote: > >> For text contents, we already have this (pasted right from the doc): > >> > >> testdb=> \set content `cat my_file.txt` > >> testdb=> INSERT INTO my_table VALUES (:'content'); > >> > >> Maybe w

Re: [HACKERS] proposal: psql \setfileref

2016-11-16 Thread Robert Haas
On Tue, Nov 15, 2016 at 11:48 AM, Pavel Stehule wrote: >> For text contents, we already have this (pasted right from the doc): >> >> testdb=> \set content `cat my_file.txt` >> testdb=> INSERT INTO my_table VALUES (:'content'); >> >> Maybe we might look at why it doesn't work for binary string and

Re: [HACKERS] proposal: psql \setfileref

2016-11-15 Thread Pavel Stehule
2016-11-15 17:39 GMT+01:00 Daniel Verite : > Corey Huinker wrote: > > > I am not asking for this feature now, but do you see any barriers to > later > > adding x/xq/xb/xbq equivalents for executing a shell command? > > For text contents, we already have this (pasted right from the doc): >

Re: [HACKERS] proposal: psql \setfileref

2016-11-15 Thread Daniel Verite
Corey Huinker wrote: > I am not asking for this feature now, but do you see any barriers to later > adding x/xq/xb/xbq equivalents for executing a shell command? For text contents, we already have this (pasted right from the doc): testdb=> \set content `cat my_file.txt` testdb=> INSERT I

Re: [HACKERS] proposal: psql \setfileref

2016-11-15 Thread Pavel Stehule
Hi 2016-11-13 19:46 GMT+01:00 Pavel Stehule : > Hi > > I am sending a initial implementation of psql content commands. This > design is reaction to Tom's objections against psql file ref variables. > This design is more cleaner, more explicit and more practical - import can > be in one step. > >

Re: [HACKERS] proposal: psql \setfileref

2016-11-15 Thread Pavel Stehule
2016-11-15 16:41 GMT+01:00 Corey Huinker : > > On Sun, Nov 13, 2016 at 1:46 PM, Pavel Stehule > wrote: > >> r - read file without any modification >> rq - read file, escape as literal and use outer quotes >> rb - read binary file - transform to hex code string >> rbq - read binary file, transform

Re: [HACKERS] proposal: psql \setfileref

2016-11-15 Thread Corey Huinker
On Sun, Nov 13, 2016 at 1:46 PM, Pavel Stehule wrote: > r - read file without any modification > rq - read file, escape as literal and use outer quotes > rb - read binary file - transform to hex code string > rbq - read binary file, transform to hex code string and use outer quotes > > Usage: I

Re: [HACKERS] proposal: psql \setfileref

2016-11-13 Thread Pavel Stehule
Hi I am sending a initial implementation of psql content commands. This design is reaction to Tom's objections against psql file ref variables. This design is more cleaner, more explicit and more practical - import can be in one step. Now supported commands are: r - read file without any modific

Re: [HACKERS] proposal: psql \setfileref

2016-11-12 Thread Pavel Stehule
2016-11-10 18:56 GMT+01:00 Tom Lane : > Pavel Stehule writes: > > 2016-11-09 22:47 GMT+01:00 Tom Lane : > >> * I really dislike the notion of keying the behavior to a special type > of > >> psql variable. > > > still I am thinking so some differencing can be nice, because we can use > > psql file

Re: [HACKERS] proposal: psql \setfileref

2016-11-10 Thread Pavel Stehule
2016-11-10 18:56 GMT+01:00 Tom Lane : > Pavel Stehule writes: > > 2016-11-09 22:47 GMT+01:00 Tom Lane : > >> * I really dislike the notion of keying the behavior to a special type > of > >> psql variable. > > > still I am thinking so some differencing can be nice, because we can use > > psql file

Re: [HACKERS] proposal: psql \setfileref

2016-11-10 Thread Tom Lane
Pavel Stehule writes: > 2016-11-09 22:47 GMT+01:00 Tom Lane : >> * I really dislike the notion of keying the behavior to a special type of >> psql variable. > still I am thinking so some differencing can be nice, because we can use > psql file path tab autocomplete. > Maybe \setfileref can stay -

Re: [HACKERS] proposal: psql \setfileref

2016-11-10 Thread Pavel Stehule
Hi 2016-11-09 22:47 GMT+01:00 Tom Lane : > Pavel Stehule writes: > > [ psql-setfileref-2016-10-11.patch ] > > I haven't been paying any attention to this thread, but I got around to > looking at it finally. I follow the idea of wanting to be able to shove > the contents of a file into a query l

Re: [HACKERS] proposal: psql \setfileref

2016-11-09 Thread Tom Lane
Pavel Stehule writes: > [ psql-setfileref-2016-10-11.patch ] I haven't been paying any attention to this thread, but I got around to looking at it finally. I follow the idea of wanting to be able to shove the contents of a file into a query literal, but there isn't much else that I like about th

Re: [HACKERS] proposal: psql \setfileref

2016-10-11 Thread Pavel Stehule
2016-10-11 9:32 GMT+02:00 Gilles Darold : > Le 11/10/2016 à 07:53, Pavel Stehule a écrit : > > > > 2016-10-10 19:50 GMT+02:00 Pavel Stehule : > >> >> >> 2016-10-10 15:17 GMT+02:00 Gilles Darold : >> >>> Le 10/10/2016 à 14:38, Daniel Verite a écrit : >>> > Gilles Darold wrote: >>> > >>> >>

Re: [HACKERS] proposal: psql \setfileref

2016-10-11 Thread Gilles Darold
Le 11/10/2016 à 07:53, Pavel Stehule a écrit : > > > 2016-10-10 19:50 GMT+02:00 Pavel Stehule >: > > > > 2016-10-10 15:17 GMT+02:00 Gilles Darold >: > > Le 10/10/2016 à 14:38, Daniel Verite a écrit : > >

Re: [HACKERS] proposal: psql \setfileref

2016-10-10 Thread Pavel Stehule
2016-10-10 19:50 GMT+02:00 Pavel Stehule : > > > 2016-10-10 15:17 GMT+02:00 Gilles Darold : > >> Le 10/10/2016 à 14:38, Daniel Verite a écrit : >> > Gilles Darold wrote: >> > >> >>postgres=# \setfileref b /dev/random >> >>postgres=# insert into test (:b); >> >> >> >> Process need to

Re: [HACKERS] proposal: psql \setfileref

2016-10-10 Thread Pavel Stehule
2016-10-10 15:17 GMT+02:00 Gilles Darold : > Le 10/10/2016 à 14:38, Daniel Verite a écrit : > > Gilles Darold wrote: > > > >>postgres=# \setfileref b /dev/random > >>postgres=# insert into test (:b); > >> > >> Process need to be killed using SIGTERM. > > This can be fixed by setting

Re: [HACKERS] proposal: psql \setfileref

2016-10-10 Thread Gilles Darold
Le 10/10/2016 à 14:38, Daniel Verite a écrit : > Gilles Darold wrote: > >>postgres=# \setfileref b /dev/random >>postgres=# insert into test (:b); >> >> Process need to be killed using SIGTERM. > This can be fixed by setting sigint_interrupt_enabled to true > before operating on the f

Re: [HACKERS] proposal: psql \setfileref

2016-10-10 Thread Daniel Verite
Gilles Darold wrote: >postgres=# \setfileref b /dev/random >postgres=# insert into test (:b); > > Process need to be killed using SIGTERM. This can be fixed by setting sigint_interrupt_enabled to true before operating on the file. Then ctrl-C would be able to cancel the command.

Re: [HACKERS] proposal: psql \setfileref

2016-10-10 Thread Gilles Darold
Le 09/10/2016 à 11:48, Pavel Stehule a écrit : > hi > > 2016-10-04 9:18 GMT+02:00 Gilles Darold >: > > Le 03/10/2016 à 23:23, Gilles Darold a écrit : > > Le 03/10/2016 à 23:03, Robert Haas a écrit : > >> On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold >

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Pavel Stehule
2016-10-10 5:26 GMT+02:00 Jim Nasby : > On 10/9/16 9:54 PM, Bruce Momjian wrote: > >> I understand, but I am not sure how difficult implementation it is. This >>> part >>> > (COPY input) doesn't support parametrization - and parametrization can >>> have a >>> > negative performance impact. >>> >>

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Corey Huinker
On Sun, Oct 9, 2016 at 11:26 PM, Jim Nasby wrote: > On 10/9/16 9:54 PM, Bruce Momjian wrote: > >> I understand, but I am not sure how difficult implementation it is. This >>> part >>> > (COPY input) doesn't support parametrization - and parametrization can >>> have a >>> > negative performance im

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Jim Nasby
On 10/9/16 9:54 PM, Bruce Momjian wrote: I understand, but I am not sure how difficult implementation it is. This part > (COPY input) doesn't support parametrization - and parametrization can have a > negative performance impact. And it would need to be \:file_ref in COPY so real data doesn't tr

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Bruce Momjian
On Sun, Oct 9, 2016 at 06:12:16PM +0200, Pavel Stehule wrote: > > > 2016-10-09 17:27 GMT+02:00 Corey Huinker : > > here is new update - some mentioned issues are fixed + regress > tests and docs > > > > >   > This might tie into some work I'm doing. Is

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Pavel Stehule
2016-10-09 19:27 GMT+02:00 Corey Huinker : > look to code - some parts allows psql session variables, some not - I can >> use variables in statements - not in data block. >> >> More, there is ambiguity - :xxx should not be part of SQL statement (and >> then psql variables are possible), but :

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Corey Huinker
> > look to code - some parts allows psql session variables, some not - I can > use variables in statements - not in data block. > > More, there is ambiguity - :xxx should not be part of SQL statement (and > then psql variables are possible), but : should be part of data. > > Regards > > Pavel

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Pavel Stehule
2016-10-09 19:14 GMT+02:00 Corey Huinker : > On Sun, Oct 9, 2016 at 12:12 PM, Pavel Stehule > wrote: > >> >> >> 2016-10-09 17:27 GMT+02:00 Corey Huinker : >> >>> here is new update - some mentioned issues are fixed + regress tests and > docs > >>> This might tie into some w

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Corey Huinker
On Sun, Oct 9, 2016 at 12:12 PM, Pavel Stehule wrote: > > > 2016-10-09 17:27 GMT+02:00 Corey Huinker : > >> here is new update - some mentioned issues are fixed + regress tests and docs >>> >>> >>> >> This might tie into some work I'm doing. Is there any way these filerefs >> could be u

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Pavel Stehule
2016-10-09 17:27 GMT+02:00 Corey Huinker : > here is new update - some mentioned issues are fixed + regress tests and >>> docs >>> >> >> >> > This might tie into some work I'm doing. Is there any way these filerefs > could be used as the inline portion of a COPY command? > i.e. like this: > > COPY

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Corey Huinker
> > here is new update - some mentioned issues are fixed + regress tests and >> docs >> > > > This might tie into some work I'm doing. Is there any way these filerefs could be used as the inline portion of a COPY command? i.e. like this: COPY my_table FROM STDIN :file_ref \.

Re: [HACKERS] proposal: psql \setfileref

2016-10-09 Thread Pavel Stehule
hi 2016-10-04 9:18 GMT+02:00 Gilles Darold : > Le 03/10/2016 à 23:23, Gilles Darold a écrit : > > Le 03/10/2016 à 23:03, Robert Haas a écrit : > >> On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold > wrote: > >>> 4) An other problem is that like this this patch will allow anyone to > upload into a >

Re: [HACKERS] proposal: psql \setfileref

2016-10-04 Thread Gilles Darold
Le 04/10/2016 à 17:29, Pavel Stehule a écrit : > > > 2016-10-04 9:18 GMT+02:00 Gilles Darold >: > > Le 03/10/2016 à 23:23, Gilles Darold a écrit : > > Le 03/10/2016 à 23:03, Robert Haas a écrit : > >> On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold >

Re: [HACKERS] proposal: psql \setfileref

2016-10-04 Thread Pavel Stehule
2016-10-04 9:18 GMT+02:00 Gilles Darold : > Le 03/10/2016 à 23:23, Gilles Darold a écrit : > > Le 03/10/2016 à 23:03, Robert Haas a écrit : > >> On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold > wrote: > >>> 4) An other problem is that like this this patch will allow anyone to > upload into a > >>>

Re: [HACKERS] proposal: psql \setfileref

2016-10-04 Thread Gilles Darold
Le 03/10/2016 à 23:23, Gilles Darold a écrit : > Le 03/10/2016 à 23:03, Robert Haas a écrit : >> On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold wrote: >>> 4) An other problem is that like this this patch will allow anyone to >>> upload into a >>> column the content of any system file that can be r

Re: [HACKERS] proposal: psql \setfileref

2016-10-03 Thread Gilles Darold
Le 03/10/2016 à 23:03, Robert Haas a écrit : > On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold wrote: >> 4) An other problem is that like this this patch will allow anyone to upload >> into a >> column the content of any system file that can be read by postgres system >> user >> and then allow non

Re: [HACKERS] proposal: psql \setfileref

2016-10-03 Thread Robert Haas
On Mon, Oct 3, 2016 at 3:54 PM, Gilles Darold wrote: > 4) An other problem is that like this this patch will allow anyone to upload > into a > column the content of any system file that can be read by postgres system user > and then allow non system user to read its content. I thought this was a

Re: [HACKERS] proposal: psql \setfileref

2016-10-03 Thread Gilles Darold
The following review has been posted through the commitfest application: make installcheck-world: tested, passed Implements feature: tested, failed Spec compliant: tested, failed Documentation:not tested Contents & Purpose == This patch adds a new type

Re: [HACKERS] proposal: psql \setfileref

2016-09-26 Thread Pavel Stehule
2016-09-26 21:47 GMT+02:00 Ryan Murphy : > > >> please, can you check attached patch? It worked in my laptop. >> >> Regards >> >> Pavel >> >> > Yes, that one applied for me without any problems. > Great, Thank you Pavel > > Thanks, > Ryan >

Re: [HACKERS] proposal: psql \setfileref

2016-09-26 Thread Ryan Murphy
> > please, can you check attached patch? It worked in my laptop. > > Regards > > Pavel > > Yes, that one applied for me without any problems. Thanks, Ryan

Re: [HACKERS] proposal: psql \setfileref

2016-09-26 Thread Pavel Stehule
Hi 2016-09-26 14:57 GMT+02:00 Ryan Murphy : > Hi Pavel, > > I just tried to apply your patch psql-setfileref-initial.patch (using git > apply) to the newest revision of postgres at the time (da6c4f6ca88) and it > failed to patch startup.c. Thinking that the patch was for some previous > revision

Re: [HACKERS] proposal: psql \setfileref

2016-09-26 Thread Pavel Stehule
2016-09-26 14:57 GMT+02:00 Ryan Murphy : > Hi Pavel, > > I just tried to apply your patch psql-setfileref-initial.patch (using git > apply) to the newest revision of postgres at the time (da6c4f6ca88) and it > failed to patch startup.c. Thinking that the patch was for some previous > revision, I

Re: [HACKERS] proposal: psql \setfileref

2016-09-26 Thread Ryan Murphy
Hi Pavel, I just tried to apply your patch psql-setfileref-initial.patch (using git apply) to the newest revision of postgres at the time (da6c4f6ca88) and it failed to patch startup.c. Thinking that the patch was for some previous revision, I then checked out d062245b5, which was from 2016-08

Re: [HACKERS] proposal: psql \setfileref

2016-08-31 Thread Pavel Stehule
2016-08-31 18:24 GMT+02:00 Corey Huinker : > On Wed, Aug 31, 2016 at 11:32 AM, Pavel Stehule > wrote: > >> 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 necessit

Re: [HACKERS] proposal: psql \setfileref

2016-08-31 Thread Corey Huinker
On Wed, Aug 31, 2016 at 11:32 AM, Pavel Stehule wrote: > 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

[HACKERS] proposal: psql \setfileref

2016-08-31 Thread Pavel Stehule
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 escape