Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-16 Thread Dimitri Fontaine
Itagaki Takahiro itagaki.takah...@gmail.com writes: I applied the attached patch extracted from Dimitri's work. Thanks! I'm working on next extension's patch, merging now. Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support -- Sent via

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-15 Thread Itagaki Takahiro
On Wed, Dec 15, 2010 at 12:55, Robert Haas robertmh...@gmail.com wrote: It seems like pg_read_binary_file() is good to have regardless of whatever else we decide to do here.  Should we pull that part out and commit it separately? The whole-file versions seem like a good idea - my only

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: Has anyone thought twice about the security implications of that? Not to mention that in most cases, the very last thing we want is to have to specify an exact full path? Well, the security is left same as before, superuser only. And Itagaki showed that

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: CREATE EXTENSION will be superuser to start with, no doubt, but I think we'll someday want to allow it to database owners, just as happened with CREATE LANGUAGE. Let's not build it on top of operations that inherently involve security problems, especially

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Dimitri Fontaine
Robert Haas robertmh...@gmail.com writes: Well, I think it is best when a patch has just one purpose. This seems to be sort of an odd hodge-podge of things. The purpose here is clean-up the existing pg_read_file() facility so that it's easy to build pg_execute_sql_file() on top of it.

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Itagaki Takahiro
On Tue, Dec 14, 2010 at 18:01, Dimitri Fontaine dimi...@2ndquadrant.fr wrote: In any case, I concur with what I gather Robert is thinking, which is that there is no good reason to be exposing any of this at the SQL level. That used to be done this way, you know, in versions between 0 and 6 of

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Robert Haas
On Tue, Dec 14, 2010 at 11:48 AM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: I'm confused which part of the patch is the point of the discussion.  1. Relax pg_read_file() to be able to read any files.  2. pg_read_binary_file()  3. pg_execute_sql_string/file() As I pointed out, 1 is

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: So there are really four changes in here, right? 1. Relax pg_read_file() to be able to read any files. 2. pg_read_binary_file() 3. pg_execute_sql_string()/file() 4. ability to read a file in a given encoding (rather than the client encoding) I

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Robert Haas
On Tue, Dec 14, 2010 at 1:38 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: So there are really four changes in here, right? 1. Relax pg_read_file() to be able to read any files. 2. pg_read_binary_file() 3. pg_execute_sql_string()/file() 4. ability to read

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: Robert Haas robertmh...@gmail.com writes: So there are really four changes in here, right? 1. Relax pg_read_file() to be able to read any files. 2. pg_read_binary_file() 3. pg_execute_sql_string()/file() 4. ability to read a file in a given encoding

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Itagaki Takahiro
On Wed, Dec 15, 2010 at 04:39, Dimitri Fontaine dimi...@2ndquadrant.fr wrote: Well, in fact, the extension's code is using either execute_sql_file() or read_text_file_with_endoding() then @extschema@ replacement then execute_sql_string(), all those functions called directly thanks to #include

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Itagaki Takahiro
On Wed, Dec 15, 2010 at 03:42, Robert Haas robertmh...@gmail.com wrote: I think #2 might be a nice thing to have, but I'm not sure what it has to do with extensions. Agreed.  There might be some use for #4 in connection with extensions, but I don't see that #2 is related. BTW, it appears to

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Robert Haas
On Tue, Dec 14, 2010 at 9:25 PM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: On Wed, Dec 15, 2010 at 03:42, Robert Haas robertmh...@gmail.com wrote: I think #2 might be a nice thing to have, but I'm not sure what it has to do with extensions. Agreed.  There might be some use for #4 in

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Itagaki Takahiro
On Wed, Dec 15, 2010 at 12:20, Robert Haas robertmh...@gmail.com wrote: It seems like pg_read_binary_file() is good to have regardless of whatever else we decide to do here.  Should we pull that part out and commit it separately? OK, I'll do that, but I have some questions: #1 Should we add

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-14 Thread Robert Haas
On Tue, Dec 14, 2010 at 10:43 PM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: On Wed, Dec 15, 2010 at 12:20, Robert Haas robertmh...@gmail.com wrote: It seems like pg_read_binary_file() is good to have regardless of whatever else we decide to do here.  Should we pull that part out and

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Itagaki Takahiro
On Sun, Dec 12, 2010 at 06:08, Dimitri Fontaine dimi...@2ndquadrant.fr wrote: The other infrastructure patch that has been mark ready for commit then commented further upon by Tom is $subject, even if the function provided as been renamed to pg_execute_sql_file(). Please find attached the

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Dimitri Fontaine
Itagaki Takahiro itagaki.takah...@gmail.com writes: I think the version is almost OK, but I have a couple of comments: - Why do you need directory_fctx in genfile.h ? I then use it in extension.c, this way: typedef struct extension_fctx { directory_fctx dir; ExtensionList

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Robert Haas
On Mon, Dec 13, 2010 at 9:36 AM, Dimitri Fontaine dimi...@2ndquadrant.fr wrote: Do you want another patch version from me? I'm looking at this patch and I'm confused. Why do we need this at all? pg_read_binary_file() seems like it might be useful to somebody, but I don't see what it has to do

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Itagaki Takahiro
On Tue, Dec 14, 2010 at 10:53, Robert Haas robertmh...@gmail.com wrote: I'm looking at this patch and I'm confused.  Why do we need this at all?  pg_read_binary_file() seems like it might be useful to somebody, but I don't see what it has to do with extensions.  And the rest of this doesn't

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Tom Lane
Itagaki Takahiro itagaki.takah...@gmail.com writes: On Tue, Dec 14, 2010 at 10:53, Robert Haas robertmh...@gmail.com wrote: I'm looking at this patch and I'm confused.  Why do we need this at all?  pg_read_binary_file() seems like it might be useful to somebody, but I don't see what it has

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Robert Haas
On Mon, Dec 13, 2010 at 9:41 PM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: Hmm, I've expected that the EXTENSION patch would use the SQL functions like as SPI_exec(SELECT pg_execute_sql(pg_read_file($1)), ...), but it actually uses internal functions and nested DirectFunctionCalls.

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Itagaki Takahiro
On Tue, Dec 14, 2010 at 12:02, Robert Haas robertmh...@gmail.com wrote: On Mon, Dec 13, 2010 at 9:41 PM, Itagaki Takahiro So, the most important part of this patch is allowing to read any files in the server file system. The current pg_read_file() allows to read only files under $PGDATA and

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Tom Lane
Itagaki Takahiro itagaki.takah...@gmail.com writes: On Tue, Dec 14, 2010 at 12:02, Robert Haas robertmh...@gmail.com wrote: As Tom says, this is clearly not going to fly on security grounds. If it's a security hole, lo_import() should be also a hole because we can use lo_import() and SELECT *

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Robert Haas
On Mon, Dec 13, 2010 at 10:21 PM, Itagaki Takahiro itagaki.takah...@gmail.com wrote: I don't have any problem with a separate patch to try to improve some of these issues, but this is supposedly part of the extensions work, yet (1) most of what's here has little to do with extensions and (2)

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Itagaki Takahiro
On Tue, Dec 14, 2010 at 12:47, Tom Lane t...@sss.pgh.pa.us wrote: lo_import is superuser-only.  If we design this feature so that it will forever have to be superuser-only, to get a behavior that I think we don't even *want*, I believe we're making a serious error. CREATE EXTENSION and

Re: [HACKERS] pg_execute_from_file, patch v10

2010-12-13 Thread Tom Lane
Itagaki Takahiro itagaki.takah...@gmail.com writes: On Tue, Dec 14, 2010 at 12:47, Tom Lane t...@sss.pgh.pa.us wrote: lo_import is superuser-only.  If we design this feature so that it will forever have to be superuser-only, to get a behavior that I think we don't even *want*, I believe we're

[HACKERS] pg_execute_from_file, patch v10

2010-12-11 Thread Dimitri Fontaine
Hi, The other infrastructure patch that has been mark ready for commit then commented further upon by Tom is $subject, even if the function provided as been renamed to pg_execute_sql_file(). Please find attached the newer version that fixes Tom concerns, removing the VARIADIC forms of the