Re: reloptions with a "namespace" - Mailing list pgsql-hackers

From Euler Taveira de Oliveira
Subject Re: reloptions with a "namespace"
Date
Msg-id 4983D537.20607@timbira.com
Whole thread Raw
In response to Re: reloptions with a "namespace"  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: reloptions with a "namespace"
Re: reloptions with a "namespace"
List pgsql-hackers
Alvaro Herrera escreveu:
> New patch attached, with pg_dump support (thanks to Tom for the SQL
> heads-up).
>
Great! We're close. Just two minor gripes:

+     char       *validnsps[] = { "toast" };

Surely, you forgot to add a NULL at the end. Patch is attached.

IIRC, my last patch includes a partial validation code for RESET cases. For
example, the last SQL will not be atomic (invalid reloption silently ignored).
So, why not apply the namespace validation code to RESET case too? Patch is
attached too. It does not handle the reloptions validation because the relOpts
initialization code is at parseRelOptions(); i leave it for a future refactor.

euler=# create table foo (a text) with (fillfactor=10);
CREATE TABLE
euler=# \d+ foo
                 Tabela "public.foo"
 Coluna | Tipo | Modificadores | Storage  | Descrição
--------+------+---------------+----------+-----------
 a      | text |               | extended |
Têm OIDs: não
Options: fillfactor=10

euler=# alter table foo reset (fillfactor,foo.fillfactor);
ALTER TABLE
euler=# \d+ foo
                 Tabela "public.foo"
 Coluna | Tipo | Modificadores | Storage  | Descrição
--------+------+---------------+----------+-----------
 a      | text |               | extended |
Têm OIDs: não


--
  Euler Taveira de Oliveira
  http://www.timbira.com/
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- Name: plperl; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: euler
--

CREATE PROCEDURAL LANGUAGE plperl;


ALTER PROCEDURAL LANGUAGE plperl OWNER TO euler;

--
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: euler
--

CREATE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO euler;

--
-- Name: plpythonu; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: euler
--

CREATE PROCEDURAL LANGUAGE plpythonu;


ALTER PROCEDURAL LANGUAGE plpythonu OWNER TO euler;

--
-- Name: pltcl; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: euler
--

CREATE PROCEDURAL LANGUAGE pltcl;


ALTER PROCEDURAL LANGUAGE pltcl OWNER TO euler;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: tst1; Type: TABLE; Schema: public; Owner: euler; Tablespace:
--

CREATE TABLE tst1 (
    a text
)
WITH (fillfactor=10);


ALTER TABLE public.tst1 OWNER TO euler;

--
-- Name: tst2; Type: TABLE; Schema: public; Owner: euler; Tablespace:
--

CREATE TABLE tst2 (
    a text
)
WITH (toast.fillfactor=20);


ALTER TABLE public.tst2 OWNER TO euler;

--
-- Name: tst3; Type: TABLE; Schema: public; Owner: euler; Tablespace:
--

CREATE TABLE tst3 (
    a text
)
WITH (fillfactor=10, toast.fillfactor=20);


ALTER TABLE public.tst3 OWNER TO euler;

--
-- Data for Name: tst1; Type: TABLE DATA; Schema: public; Owner: euler
--

COPY tst1 (a) FROM stdin;
\.


--
-- Data for Name: tst2; Type: TABLE DATA; Schema: public; Owner: euler
--

COPY tst2 (a) FROM stdin;
\.


--
-- Data for Name: tst3; Type: TABLE DATA; Schema: public; Owner: euler
--

COPY tst3 (a) FROM stdin;
\.


--
-- Name: public; Type: ACL; Schema: -; Owner: euler
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM euler;
GRANT ALL ON SCHEMA public TO euler;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- PostgreSQL database dump complete
--

*** pgsql.alvaro/src/backend/access/common/reloptions.c    2009-01-31 02:01:21.000000000 -0200
--- pgsql.euler/src/backend/access/common/reloptions.c    2009-01-31 02:16:29.000000000 -0200
***************
*** 487,492 ****
--- 487,519 ----
      {
          ReloptElem    *def = lfirst(cell);

+         /*
+          * Error out if the namespace is not valid.  A NULL namespace
+          * is always valid.
+          */
+         if (def->nmspc != NULL)
+         {
+             bool    valid = false;
+             int        i;
+
+             if (validnsps)
+             {
+                 for (i = 0; validnsps[i]; i++)
+                 {
+                     if (pg_strcasecmp(def->nmspc, validnsps[i]) == 0)
+                     {
+                         valid = true;
+                         break;
+                     }
+                 }
+             }
+
+             if (!valid)
+                 ereport(ERROR,
+                         (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                          errmsg("unrecognized parameter namespace \"%s\"",
+                                 def->nmspc)));
+         }

          if (isReset)
          {
***************
*** 501,534 ****
              const char *value;
              Size        len;

-             /*
-              * Error out if the namespace is not valid.  A NULL namespace
-              * is always valid.
-              */
-             if (def->nmspc != NULL)
-             {
-                 bool    valid = false;
-                 int        i;
-
-                 if (validnsps)
-                 {
-                     for (i = 0; validnsps[i]; i++)
-                     {
-                         if (pg_strcasecmp(def->nmspc, validnsps[i]) == 0)
-                         {
-                             valid = true;
-                             break;
-                         }
-                     }
-                 }
-
-                 if (!valid)
-                     ereport(ERROR,
-                             (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                              errmsg("unrecognized parameter namespace \"%s\"",
-                                     def->nmspc)));
-             }
-
              if (ignoreOids && pg_strcasecmp(def->optname, "oids") == 0)
                  continue;

--- 528,533 ----

pgsql-hackers by date:

Previous
From: Robert Treat
Date:
Subject: Re: 8.4 release planning
Next
From: Euler Taveira de Oliveira
Date:
Subject: Re: reloptions with a "namespace"