Re: in-catalog Extension Scripts and Control parameters (templates?) - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: in-catalog Extension Scripts and Control parameters (templates?)
Date
Msg-id 20130701165547.GG3757@eldon.alvh.no-ip.org
Whole thread Raw
In response to Re: in-catalog Extension Scripts and Control parameters (templates?)  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
List pgsql-hackers
I think this is unlikely to work reliably:

+   PG_TRY();
+   {
+       ExtensionControl *control = read_extension_control_file(extname);
+ 
+       if (control)
+       {
+           ereport(ERROR,
+                   (errcode(ERRCODE_DUPLICATE_OBJECT),
+                    errmsg("extension \"%s\" is already available", extname)));
+       }
+   }
+   PG_CATCH();
+   {
+       /* no control file found is good news for us */
+   }
+   PG_END_TRY();

What if read_extension_control_file() fails because of an out-of-memory
error?  I think you need to extend that function to have a more useful
API, not rely on it raising a specific error.  There is at least one
more case when you're calling that function in the same way.

It'd probably work to have a boolean return (found/not found), and
return the ExtensionControl structure through a pointer.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: fallocate / posix_fallocate for new WAL file creation (etc...)
Next
From: Atri Sharma
Date:
Subject: Re: Randomisation for ensuring nlogn complexity in quicksort