where to add/change commands
Hi folks
I am trying to make CLUSTER command just a bit verbose,as an option
here. Added bits to gram.y that should support CLUSTER [VERBOSE] ...
but psql doesn't seem to pick it up.
Where else do I need to update it, besides gram.y, cluster.c and of
course adding new field to ClusterStmt.
I tried seaching the list for such hints, but didn't found anything
usefull.
thanks.
--
Grzegorz Jaskiewicz
gj@pointblue.com.pl
C/C++ Freelance to hire.
Grzegorz Jaskiewicz wrote:
I am trying to make CLUSTER command just a bit verbose,as an option
here. Added bits to gram.y that should support CLUSTER [VERBOSE] ... but
psql doesn't seem to pick it up.
psql? There's some code to detect commands that can't be run in a
transaction block in src/bin/psql/common.c, maybe that's what you're
looking for.
Or did you mean something else? How doesn't it "pick it up"?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
On Mar 15, 2007, at 11:36 AM, Heikki Linnakangas wrote:
Grzegorz Jaskiewicz wrote:
I am trying to make CLUSTER command just a bit verbose,as an
option here. Added bits to gram.y that should support CLUSTER
[VERBOSE] ... but psql doesn't seem to pick it up.psql? There's some code to detect commands that can't be run in a
transaction block in src/bin/psql/common.c, maybe that's what
you're looking for.
meaning that if I type in "CLUSTER VERBOSE" in psql, I get syntax error.
Or did you mean something else? How doesn't it "pick it up"?
well, probably patch's worth 1000 words. Hope that attaching such
small file isn't a crime in the neck'o'woods.
Attachments:
clusterverbose.patchapplication/octet-stream; name=clusterverbose.patch; x-unix-mode=0644Download
Index: src/backend/commands/cluster.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/cluster.c,v
retrieving revision 1.157
diff -u -r1.157 cluster.c
--- src/backend/commands/cluster.c 13 Mar 2007 00:33:39 -0000 1.157
+++ src/backend/commands/cluster.c 15 Mar 2007 10:38:03 -0000
@@ -84,6 +84,12 @@
void
cluster(ClusterStmt *stmt, bool isTopLevel)
{
+ if (stmt->verbose == true)
+ {
+ ereport(INFO, (errmsg("verbose it is") ) );
+
+ }
+
if (stmt->relation != NULL)
{
/* This is the single-relation case. */
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.581
diff -u -r2.581 gram.y
--- src/backend/parser/gram.y 13 Mar 2007 00:33:41 -0000 2.581
+++ src/backend/parser/gram.y 15 Mar 2007 10:38:07 -0000
@@ -5277,29 +5277,38 @@
*****************************************************************************/
ClusterStmt:
- CLUSTER index_name ON qualified_name
+ CLUSTER opt_verbose index_name ON qualified_name
{
ClusterStmt *n = makeNode(ClusterStmt);
- n->relation = $4;
- n->indexname = $2;
+ n->relation = $5;
+ n->verbose = $2;
+ n->indexname = $3;
$$ = (Node*)n;
}
- | CLUSTER qualified_name
+ | CLUSTER opt_verbose qualified_name
{
ClusterStmt *n = makeNode(ClusterStmt);
- n->relation = $2;
+ n->relation = $3;
+ n->verbose = $2;
n->indexname = NULL;
$$ = (Node*)n;
}
- | CLUSTER
+ | CLUSTER opt_verbose
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = NULL;
+ n->verbose = $2;
n->indexname = NULL;
$$ = (Node*)n;
}
;
+opt_verbose:
+ VERBOSE { $$ = TRUE; }
+ | /*EMPTY*/ { $$ = FALSE; }
+ ;
+
+
/*****************************************************************************
*
* QUERY:
@@ -5375,10 +5384,6 @@
| ANALYSE /* British */ {}
;
-opt_verbose:
- VERBOSE { $$ = TRUE; }
- | /*EMPTY*/ { $$ = FALSE; }
- ;
opt_full: FULL { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.342
diff -u -r1.342 parsenodes.h
--- src/include/nodes/parsenodes.h 13 Mar 2007 00:33:43 -0000 1.342
+++ src/include/nodes/parsenodes.h 15 Mar 2007 10:38:08 -0000
@@ -1774,6 +1774,7 @@
NodeTag type;
RangeVar *relation; /* relation being indexed, or NULL if all */
char *indexname; /* original index defined */
+ bool verbose;
} ClusterStmt;
/* ----------------------
Hi,
psql? There's some code to detect commands that can't be run in a
transaction block in src/bin/psql/common.c, maybe that's what you're
looking for.Or did you mean something else? How doesn't it "pick it up"?
I think he probably meant that he was getting a syntax error, even after
making all the changes.
Grzegorz, I would have suggested to make an entry for VERBOSE in
parser/keywords.c, but it already seems to contain an entry for VERBOSE. I
hope you are using the "opt_verbose" rule in your gram.y in the CLUSTER
[VERBOSE] case.
Regards,
Nikhils
--
EnterpriseDB http://www.enterprisedb.com
On Mar 15, 2007, at 11:46 AM, NikhilS wrote:
Grzegorz, I would have suggested to make an entry for VERBOSE in
parser/keywords.c, but it already seems to contain an entry for
VERBOSE. I hope you are using the "opt_verbose" rule in your gram.y
in the CLUSTER [VERBOSE] case.
sure I am. My 'bison' skills are not very high, but I was trying to
mimic 'VACUUM' syntax there. see the patch.
--
Grzegorz Jaskiewicz
gj@pointblue.com.pl
C/C++ freelance to hire
Grzegorz Jaskiewicz wrote:
meaning that if I type in "CLUSTER VERBOSE" in psql, I get syntax
error.
Your patch works perfectly fine for me.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
On Mar 15, 2007, at 12:26 PM, Peter Eisentraut wrote:
Your patch works perfectly fine for me.
Ok, I'll try make distclean/make -j2/sudo make install, reboot and
will see.
I was kinda beliving that remaking whole thing from scratch over and
over again wouldn't be a necessity here.
thanks.
--
Grzegorz Jaskiewicz
C/C++ freelance for hire
"Grzegorz Jaskiewicz" <gj@pointblue.com.pl> writes:
On Mar 15, 2007, at 12:26 PM, Peter Eisentraut wrote:
Your patch works perfectly fine for me.
Ok, I'll try make distclean/make -j2/sudo make install, reboot and will see.
I was kinda beliving that remaking whole thing from scratch over and over again
wouldn't be a necessity here.
thanks.
You may want to configure with --enable-depend. It shouldn't be necessary to
get make to notice changes to gram.y but perhaps your problem lies elsewhere.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
ok, it works okay.
Thanks.
I am really serious about adding this patch. I would like it to not
only show which tables/indices are being clustered, but also some
sort of progress information (print procentage of job being done, etc).
Any hints, as on what might be useful for others. Perhaps there's a
slim chance I could offer it to mainline?
--
Grzegorz Jaskiewicz
C/C++ freelance for hire