Re: pg_execute_from_file review

From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: Joshua Tolley <eggyknap(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_execute_from_file review
Date: 2010-11-25 21:24:51
Message-ID: m2eia93xlo.fsf@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Joshua Tolley <eggyknap(at)gmail(dot)com> writes:
> I've just looked at pg_execute_from_file[1]. The idea here is to execute all
> the SQL commands in a given file. My comments:

Thanks for your review. Please find attached a revised patch where I've
changed the internals of the function so that it's split in two and that
the opr_sanity check passes, per comments from David Wheeler and Tom Lane.

> * I'd like to see the docs slightly expanded, specifically to describe
> parameter replacement. I wondered for a while if I needed to set of
> parameters in any specific way, before reading the code and realizing they
> can be whatever I want.

My guess is that you knew that in the CREATE EXTENSION context, it has
been proposed to use the notation @extschema@ as a placeholder, and
you've then been confused. I've refrained from imposing any style with
respect to what the placeholder would look like in the mecanism-patch.

Do we still want to detail in the docs that there's nothing expected
about the placeholder syntax of format?

> * Does anyone think it needs representation in the test suite?

Well the patch will get its tests with the arrival of the extension main
patch, where all contribs are installed using it.

> * Is it at all bad to include spi.h in genfile.c? IOW should this function
> live elsewhere? It seems reasonable to me to do it as written, but I thought
> I'd ask.

Well, using spi at this place has been asked by Álvaro and Tom, so my
guess is that's ok :)

> * In the snippet below, it seems best just to use palloc0():
> query_string = (char *)palloc((fsize+1)*sizeof(char));
> memset(query_string, 0, fsize+1);

Edited.

> * Shouldn't it include SPI_push() and SPI_pop()?

ENOCLUE

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

Attachment Content-Type Size
pg_execute_from_file.v5.patch text/x-patch 11.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2010-11-25 22:00:06 Re: ALTER OBJECT any_name SET SCHEMA name
Previous Message Dimitri Fontaine 2010-11-25 21:06:03 Re: Extensions, this time with a patch