Re: Problemas with gram.y

Lists: pgsql-hackers
From: tmorelli(at)tmorelli(dot)com(dot)br
To: pgsql-hackers(at)postgresql(dot)org
Cc: etmorelli(at)superig(dot)com(dot)br
Subject: Problemas with gram.y
Date: 2006-03-03 21:14:45
Message-ID: 20060303211445.A6866B7F78@smtpi03.infolink.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I'm trying to extend the CREATE INDEX statement with a fillfactor clause. In
Gram.y, I did this:

IndexStmt: CREATE index_opt_unique INDEX index_name ON qualified_name
access_method_clause '(' index_params ')' fillfactor_clause where_clause
{
IndexStmt *n = makeNode(IndexStmt);
n->unique = $2;
n->idxname = $4;
n->relation = $6;
n->accessMethod = $7;
n->indexParams = $9;
n->fillfactor = $11;
n->whereClause = $12;
$$ = (Node *)n;
}

And the clause:

fillfactor_clause:
FILLFACTOR IntegerOnly { $$ = makeInteger($2); }
{ $$ = 0; };

I had to add a new field into IndexStmt (unsigned int fillfactor). Everything
is fine after parsing except that I can't see the integer value. For example,
in transformIndexStmt (analyze.c), I've inspected stmt->fillfactor and I've got
a strange, obviously wrong, value (137616352) after issuing this statement:

create index ix_desc on products(description) fillfactor 7;

Is thre any statement with numeric clauses? The only one that I found was
Alter/Create Sequence, but there is an ugly list there.

Could anyone help me, please?

Thanks a lot!


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: tmorelli(at)tmorelli(dot)com(dot)br
Cc: pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-03 21:27:23
Message-ID: 4408B4BB.1050102@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

tmorelli(at)tmorelli(dot)com(dot)br wrote:

>Hi,
>
>I'm trying to extend the CREATE INDEX statement with a fillfactor clause. In
>Gram.y, I did this:
>
>IndexStmt: CREATE index_opt_unique INDEX index_name ON qualified_name
>access_method_clause '(' index_params ')' fillfactor_clause where_clause
> {
> IndexStmt *n = makeNode(IndexStmt);
> n->unique = $2;
> n->idxname = $4;
> n->relation = $6;
> n->accessMethod = $7;
> n->indexParams = $9;
> n->fillfactor = $11;
> n->whereClause = $12;
> $$ = (Node *)n;
> }
>
>And the clause:
>
>fillfactor_clause:
>FILLFACTOR IntegerOnly { $$ = makeInteger($2); }
> { $$ = 0; };
>
>I had to add a new field into IndexStmt (unsigned int fillfactor). Everything
>is fine after parsing except that I can't see the integer value. For example,
>in transformIndexStmt (analyze.c), I've inspected stmt->fillfactor and I've got
> a strange, obviously wrong, value (137616352) after issuing this statement:
>
>create index ix_desc on products(description) fillfactor 7;
>
>Is thre any statement with numeric clauses? The only one that I found was
>Alter/Create Sequence, but there is an ugly list there.
>
>Could anyone help me, please?
>
>Thanks a lot!
>
>
>
>

did you change nodes/copyfuncs.c and nodes/equalfuncs.c as you have to
do when you add new node fields?

cheers

andrew


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: tmorelli(at)tmorelli(dot)com(dot)br
Cc: pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-03 21:32:59
Message-ID: 20060303213259.GE17615@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Mar 03, 2006 at 07:14:45PM -0200, tmorelli(at)tmorelli(dot)com(dot)br wrote:
> Hi,
>
> I'm trying to extend the CREATE INDEX statement with a fillfactor clause. In
> Gram.y, I did this:

<snip>

> I had to add a new field into IndexStmt (unsigned int fillfactor). Everything
> is fine after parsing except that I can't see the integer value. For example,
> in transformIndexStmt (analyze.c), I've inspected stmt->fillfactor and I've got
> a strange, obviously wrong, value (137616352) after issuing this statement:

Did you update infunc/outfuncs/copyfuns in the nodes directory? They're
used to copy the nodes and if you forget to update them you get strange
numbers instead.

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: tmorelli(at)tmorelli(dot)com(dot)br
Cc: pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-03 23:36:23
Message-ID: 9086.1141428983@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

tmorelli(at)tmorelli(dot)com(dot)br writes:
> I'm trying to extend the CREATE INDEX statement with a fillfactor
> clause.

Um, are you aware that a patch for that was already submitted?
http://momjian.postgresql.org/cgi-bin/pgpatches

I find the whole idea pretty ugly myself.

regards, tom lane


From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: tmorelli(at)tmorelli(dot)com(dot)br, pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-04 05:48:52
Message-ID: c2d9e70e0603032148s61a7ecaame6c4a78fa53816a0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 3/3/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> tmorelli(at)tmorelli(dot)com(dot)br writes:
> > I'm trying to extend the CREATE INDEX statement with a fillfactor
> > clause.
>
> Um, are you aware that a patch for that was already submitted?
> http://momjian.postgresql.org/cgi-bin/pgpatches
>
> I find the whole idea pretty ugly myself.
>
> regards, tom lane
>

why? if i can ask? you didn't seem upset with that in the thread

--
regards,
Jaime Casanova

"What they (MySQL) lose in usability, they gain back in benchmarks, and that's
all that matters: getting the wrong answer really fast."
Randal L. Schwartz


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jaime Casanova" <systemguards(at)gmail(dot)com>
Cc: tmorelli(at)tmorelli(dot)com(dot)br, pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-04 06:16:55
Message-ID: 11785.1141453015@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Jaime Casanova" <systemguards(at)gmail(dot)com> writes:
> On 3/3/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I find the whole idea pretty ugly myself.

> why? if i can ask? you didn't seem upset with that in the thread

What's bugging me about it is that the proposed syntax wedges a bunch
of index-access-method-specific parameters into what ought to be an
access-method-agnostic syntax; and furthermore does it by adding more
grammar keywords, something we have far too many of already. There are
direct measurable costs to having more keywords, and the approach does
not scale up to allowing other index AMs to have other parameters that
might not bear at all on btree.

I don't object to the concept of providing some way of adjusting index
fill factors, but I'm not at all happy with doing it like this. I'd
like to see a design that has some extensibility to it.

regards, tom lane


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jaime Casanova <systemguards(at)gmail(dot)com>, tmorelli(at)tmorelli(dot)com(dot)br, pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-04 10:29:41
Message-ID: 20060304102941.GC29180@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Mar 04, 2006 at 01:16:55AM -0500, Tom Lane wrote:
> What's bugging me about it is that the proposed syntax wedges a bunch
> of index-access-method-specific parameters into what ought to be an
> access-method-agnostic syntax; and furthermore does it by adding more
> grammar keywords, something we have far too many of already. There are
> direct measurable costs to having more keywords, and the approach does
> not scale up to allowing other index AMs to have other parameters that
> might not bear at all on btree.

I think the current method is based on compatability with other
databases. However, a more generic approach would be to (re)use the
"definition" or "def_list" productions. This would allow any of the
following (examples):

CREATE INDEX foo ON bar (x) WITH (fillfactor = 70, option = blah);
CREATE INDEX foo ON bar (x) WITH fillfactor = 70, option = blah;
CREATE INDEX foo ON bar (x) (fillfactor = 70, option = blah);
CREATE INDEX foo ON bar (x) fillfactor = 70, option = blah;

All without creating any new keywords. You could also place them
before/after the USING clause although there would be some grammer
conflicts there.

Would this be better?
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Jaime Casanova <systemguards(at)gmail(dot)com>, tmorelli(at)tmorelli(dot)com(dot)br, pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-04 15:44:49
Message-ID: 14681.1141487089@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> On Sat, Mar 04, 2006 at 01:16:55AM -0500, Tom Lane wrote:
>> What's bugging me about it is that the proposed syntax wedges a bunch
>> of index-access-method-specific parameters into what ought to be an
>> access-method-agnostic syntax; and furthermore does it by adding more
>> grammar keywords, something we have far too many of already.

> I think the current method is based on compatability with other
> databases. However, a more generic approach would be to (re)use the
> "definition" or "def_list" productions. This would allow any of the
> following (examples):

> CREATE INDEX foo ON bar (x) WITH (fillfactor = 70, option = blah);
> CREATE INDEX foo ON bar (x) WITH fillfactor = 70, option = blah;
> CREATE INDEX foo ON bar (x) (fillfactor = 70, option = blah);
> CREATE INDEX foo ON bar (x) fillfactor = 70, option = blah;

Yeah, something along this line is what I'd like to see; probably the
first form since that creates the least hazard of foreclosing other
additions to the syntax later. I'm not wedded to WITH as the keyword,
but I think there should be some keyword (ie not choice #3), and I
definitely want parens around the list else it has to be the last thing
in the command.

The main thing that would have to be resolved before you could proceed
very far with this is how does pg_dump extract the index's options?
My guess is that we'd want to extend pg_index entries to store the list
of options. This could probably be done in very much the same way that
ALTER USER SET or ALTER DATABASE SET GUC options are stored, ie, an
array containing name/value pairs.

Another point is that we should take some thought now for the prospect
that the set of options might change across time. I'd be inclined to
argue that if an unknown option appears in a CREATE INDEX command, it's
better to emit a warning and then drop the option, rather than error out
--- otherwise, reloading dumps into newer PG versions will be difficult.
This will impact the details of the index AM API, because the AM will
need a way to filter the options before they get stored in pg_index.
Possibly adding a "precheck" AM function call is the answer here.

Anyway the bottom line is that we need to put in some infrastructure
that can handle multiple index parameters, not a one-off solution that
only handles PCTFREE.

regards, tom lane


From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Jaime Casanova <systemguards(at)gmail(dot)com>, tmorelli(at)tmorelli(dot)com(dot)br, pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-07 10:23:33
Message-ID: 20060307190921.4A6E.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> > CREATE INDEX foo ON bar (x) WITH (fillfactor = 70, option = blah);
>
> Yeah, something along this line is what I'd like to see; probably the
> first form since that creates the least hazard of foreclosing other
> additions to the syntax later.

> Anyway the bottom line is that we need to put in some infrastructure
> that can handle multiple index parameters, not a one-off solution that
> only handles PCTFREE.

Ok, I'll rewrite my PCTFREE patch, and change the word PCTFREE to FILLFACTOR.
There is no benefit of compatibility with Oracle now.

Current all index access methods (btree, hash and gist) have conception of
fillfactors, but static bitmap index or something may not have it.
I see that we should give priority to the design.

---
ITAGAKI Takahiro
NTT Cyber Space Laboratories


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Jaime Casanova <systemguards(at)gmail(dot)com>, tmorelli(at)tmorelli(dot)com(dot)br, pgsql-hackers(at)postgresql(dot)org, etmorelli(at)superig(dot)com(dot)br
Subject: Re: Problemas with gram.y
Date: 2006-03-08 03:25:06
Message-ID: 200603080325.k283P6O25420@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Patch withdrawn by author for reworking.

---------------------------------------------------------------------------

ITAGAKI Takahiro wrote:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> > > CREATE INDEX foo ON bar (x) WITH (fillfactor = 70, option = blah);
> >
> > Yeah, something along this line is what I'd like to see; probably the
> > first form since that creates the least hazard of foreclosing other
> > additions to the syntax later.
>
> > Anyway the bottom line is that we need to put in some infrastructure
> > that can handle multiple index parameters, not a one-off solution that
> > only handles PCTFREE.
>
> Ok, I'll rewrite my PCTFREE patch, and change the word PCTFREE to FILLFACTOR.
> There is no benefit of compatibility with Oracle now.
>
> Current all index access methods (btree, hash and gist) have conception of
> fillfactors, but static bitmap index or something may not have it.
> I see that we should give priority to the design.
>
> ---
> ITAGAKI Takahiro
> NTT Cyber Space Laboratories
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +