Re: pg_execute_from_file, patch v10
Dimitri Fontaine <dimitri@2ndquadrant.fr>
From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
To: Itagaki Takahiro <itagaki.takahiro@gmail.com>
Cc: Dimitri Fontaine <dimitri@2ndquadrant.fr>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2010-12-13T14:36:12Z
Lists: pgsql-hackers
Itagaki Takahiro <itagaki.takahiro@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 *installed;
} extension_fctx;
> - It might be reasonable to have 3 and 1 arguments version of pg_read_file.
> i.e, (path, offset, size) and (path). Two args version (path, offset)
> doesn't seem to be so useful. In addition, CREATE EXTENSION will always
> call it with offset=0, no?
Depending on the 'relocatable' property, we now do either of those calls:
execute_sql_file(get_extension_absolute_path(control->script),
pg_encoding_to_char(encoding));
read_text_file_with_endoding(filename,
pg_encoding_to_char(encoding));
So we're using the internal forms only here, and we can propose whatever
API we find best. Reading through the end of the file seems common
enough, but I agree I would prefer reading the whole file here if I had
to pick only one.
> - We don't need some of added #include "utils/array.h" anymore.
Ah yes, true.
Do you want another patch version from me?
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support