[HACKERS] BETWEEN SYMMETRIC
Hi, Based on recent discussion, I went thru and got together the work I'd done on the BETWEEN node. It's not as far along as I thought. I ran into a few hurdles: * ExecEvalBetweenExpr is probably beyond my powers - I've done my best and marked my hopelessness with '@@' symbols. I don't know how to actually evaluate the node properly, I don't know how to check that all the 3 types are coercible to the same type and I don't know how to make it take rowvars (sic?)instead of scalars, as per spec. Copy and Equal are done, I think. Out I've guessed at how to do it based on other examples, but I need feedback. Read I haven't done at all cos I don't quite understand when/why it's used or how to do it. The grammar has been updated to use the new BetweenExpr node, with new syntax options. The new keywords have been added in the relevant places, and they are reserved. nodes.h and parsenodes.h are aware of the new node. I have added a full regression test that I used in my old gram.y only implementation, that didn't use a new node - it will be helpful! Where do we go from here? Chris ? GNUmakefile ? between.diff.txt ? config.log ? config.status ? contrib/spi/.deps ? src/Makefile.global ? src/backend/postgres ? src/backend/access/common/.deps ? src/backend/access/gist/.deps ? src/backend/access/hash/.deps ? src/backend/access/heap/.deps ? src/backend/access/index/.deps ? src/backend/access/nbtree/.deps ? src/backend/access/rtree/.deps ? src/backend/access/transam/.deps ? src/backend/bootstrap/.deps ? src/backend/catalog/.deps ? src/backend/catalog/postgres.bki ? src/backend/catalog/postgres.description ? src/backend/commands/.deps ? src/backend/commands/tablecmds.c.mystuff ? src/backend/executor/.deps ? src/backend/lib/.deps ? src/backend/libpq/.deps ? src/backend/main/.deps ? src/backend/nodes/.deps ? src/backend/optimizer/geqo/.deps ? src/backend/optimizer/path/.deps ? src/backend/optimizer/plan/.deps ? src/backend/optimizer/prep/.deps ? src/backend/optimizer/util/.deps ? src/backend/parser/.deps ? src/backend/port/.deps ? src/backend/postmaster/.deps ? src/backend/regex/.deps ? src/backend/rewrite/.deps ? src/backend/storage/buffer/.deps ? src/backend/storage/file/.deps ? src/backend/storage/freespace/.deps ? src/backend/storage/ipc/.deps ? src/backend/storage/large_object/.deps ? src/backend/storage/lmgr/.deps ? src/backend/storage/page/.deps ? src/backend/storage/smgr/.deps ? src/backend/tcop/.deps ? src/backend/utils/.deps ? src/backend/utils/adt/.deps ? src/backend/utils/cache/.deps ? src/backend/utils/error/.deps ? src/backend/utils/fmgr/.deps ? src/backend/utils/hash/.deps ? src/backend/utils/init/.deps ? src/backend/utils/mb/.deps ? src/backend/utils/misc/.deps ? src/backend/utils/mmgr/.deps ? src/backend/utils/sort/.deps ? src/backend/utils/time/.deps ? src/bin/initdb/initdb ? src/bin/initlocation/initlocation ? src/bin/ipcclean/ipcclean ? src/bin/pg_config/pg_config ? src/bin/pg_ctl/pg_ctl ? src/bin/pg_dump/.deps ? src/bin/pg_dump/pg_dump ? src/bin/pg_dump/pg_dumpall ? src/bin/pg_dump/pg_restore ? src/bin/pg_encoding/.deps ? src/bin/pg_encoding/pg_encoding ? src/bin/pg_id/.deps ? src/bin/pg_id/pg_id ? src/bin/psql/.deps ? src/bin/psql/psql ? src/bin/scripts/createlang ? src/include/pg_config.h ? src/include/stamp-h ? src/interfaces/ecpg/lib/.deps ? src/interfaces/ecpg/lib/libecpg.so.3 ? src/interfaces/ecpg/preproc/.deps ? src/interfaces/ecpg/preproc/ecpg ? src/interfaces/libpgeasy/.deps ? src/interfaces/libpgeasy/libpgeasy.so.2 ? src/interfaces/libpq/.deps ? src/interfaces/libpq/libpq.so.2 ? src/interfaces/libpq++/.deps ? src/interfaces/libpq++/libpq++.so.4 ? src/pl/plpgsql/src/.deps ? src/pl/plpgsql/src/libplpgsql.so.1 ? src/test/regress/.deps ? src/test/regress/log ? src/test/regress/pg_regress ? src/test/regress/regression.diffs ? src/test/regress/regression.out ? src/test/regress/results ? src/test/regress/tmp_check ? src/test/regress/expected/constraints.out ? src/test/regress/expected/copy.out ? src/test/regress/expected/create_function_1.out ? src/test/regress/expected/create_function_2.out ? src/test/regress/expected/misc.out ? src/test/regress/sql/constraints.sql ? src/test/regress/sql/copy.sql ? src/test/regress/sql/create_function_1.sql ? src/test/regress/sql/create_function_2.sql ? src/test/regress/sql/misc.sql Index: src/backend/executor/execQual.c === RCS file: /projects/cvsroot/pgsql/src/backend/executor/execQual.c,v retrieving revision 1.94 diff -c -r1.94 execQual.c *** src/backend/executor/execQual.c 2002/06/20 20:29:27 1.94 --- src/backend/executor/execQual.c 2002/06/27 10:27:30 *** *** 60,65 --- 60,67 static Datum ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull); static Datum ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); + static Datum ExecEvalBetweenExpr(BetweenExpr *btest, ExprContext
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
TODO updated: * Add BETWEEN ASYMMETRIC/SYMMETRIC (Christopher) * Christopher is Christopher Kings-Lynne [EMAIL PROTECTED] --- Christopher Kings-Lynne wrote: Christopher Kings-Lynne [EMAIL PROTECTED] writes: Also, Tom (or anyone): in regards to your previous email, should I just go back to using opt_symmetry to shorten the number of productions, since I have to make them reserved words anyway? Might as well. No point in writing more productions if it doesn't buy anything. Since it's really just two ways of writing the same thing, wouldn't bison just produce the exact same C code? I'll rewrite it anyway for elegance, but just wondering... BTW, I've forgotten whether your patch is purely syntactic or not, but I'd really like to see someone fix things so that BETWEEN has its own expression node tree type and is not expanded into some ugly A=B and A=C equivalent. This would (a) allow it to be reverse-listed reasonably, and (b) eliminate redundant evaluations of the subexpressions. It is purely syntactic. Anyone want to give me a quick hint on how to make a new node tree type for BETWEEN? What does reverse-listing mean as well? Chris ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup.| Drexel Hill, Pennsylvania 19026 ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
TODO updated: * Add BETWEEN ASYMMETRIC/SYMMETRIC (Christopher) * Christopher is Christopher Kings-Lynne [EMAIL PROTECTED] So should I go ahead and submit a patch for BETWEEN that adds SYMMETRY support in the old-style code, and then at a later stage submit a patch that makes BETWEEN a proper node? Chris ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne wrote: TODO updated: * Add BETWEEN ASYMMETRIC/SYMMETRIC (Christopher) * Christopher is Christopher Kings-Lynne [EMAIL PROTECTED] So should I go ahead and submit a patch for BETWEEN that adds SYMMETRY support in the old-style code, and then at a later stage submit a patch that makes BETWEEN a proper node? Sure, I think that makes sense. The larger BETWEEN node code will be tricky. -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup.| Drexel Hill, Pennsylvania 19026 ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
So should I go ahead and submit a patch for BETWEEN that adds SYMMETRY support in the old-style code, and then at a later stage submit a patch that makes BETWEEN a proper node? Sure, I think that makes sense. The larger BETWEEN node code will be tricky. Question: Why have you created a special case for NOT BETWEEN? Wouldn't you just need a BETWEEN node and the NOT node will handle the NOTing? Or is it because BETWEEN isn't a node at the moment? Chris ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne wrote: So should I go ahead and submit a patch for BETWEEN that adds SYMMETRY support in the old-style code, and then at a later stage submit a patch that makes BETWEEN a proper node? Sure, I think that makes sense. The larger BETWEEN node code will be tricky. Question: Why have you created a special case for NOT BETWEEN? Wouldn't you just need a BETWEEN node and the NOT node will handle the NOTing? Or is it because BETWEEN isn't a node at the moment? Well, looking at the grammar, I don't know how I could have gotten NOT into that construction. There are two parameters separated by AND and I didn't know how to do it. -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup.| Drexel Hill, Pennsylvania 19026 ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: So should I go ahead and submit a patch for BETWEEN that adds SYMMETRY support in the old-style code, and then at a later stage submit a patch that makes BETWEEN a proper node? I'd prefer to do it in one step. I have not noticed any large groundswell of demand for BETWEEN SYMMETRIC ... so I don't see a good reason for implementing a stopgap version. (It would be a stopgap mainly because the planner wouldn't recognize it as a range query.) regards, tom lane ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: So should I go ahead and submit a patch for BETWEEN that adds SYMMETRY support in the old-style code, and then at a later stage submit a patch that makes BETWEEN a proper node? I'd prefer to do it in one step. I have not noticed any large groundswell of demand for BETWEEN SYMMETRIC ... so I don't see a good reason for implementing a stopgap version. (It would be a stopgap mainly because the planner wouldn't recognize it as a range query.) OK, I'll go for the whole change - just expect lots of questions :) Chris ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: Also, Tom (or anyone): in regards to your previous email, should I just go back to using opt_symmetry to shorten the number of productions, since I have to make them reserved words anyway? Might as well. No point in writing more productions if it doesn't buy anything. Since it's really just two ways of writing the same thing, wouldn't bison just produce the exact same C code? I'll rewrite it anyway for elegance, but just wondering... BTW, I've forgotten whether your patch is purely syntactic or not, but I'd really like to see someone fix things so that BETWEEN has its own expression node tree type and is not expanded into some ugly A=B and A=C equivalent. This would (a) allow it to be reverse-listed reasonably, and (b) eliminate redundant evaluations of the subexpressions. It is purely syntactic. Anyone want to give me a quick hint on how to make a new node tree type for BETWEEN? What does reverse-listing mean as well? Chris ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: Since it's really just two ways of writing the same thing, wouldn't bison just produce the exact same C code? I'll rewrite it anyway for elegance, but just wondering... The emitted code might or might not be the same --- but duplicate or near-duplicate chunks of source code are always best avoided, if only from a maintenance perspective. BTW, I've forgotten whether your patch is purely syntactic or not, but I'd really like to see someone fix things so that BETWEEN has its own expression node tree type and is not expanded into some ugly A=B and A=C equivalent. This would (a) allow it to be reverse-listed reasonably, and (b) eliminate redundant evaluations of the subexpressions. It is purely syntactic. Anyone want to give me a quick hint on how to make a new node tree type for BETWEEN? Try chasing the references to another extant expression node type, perhaps NullTest. It's fairly straightforward, but tedious to teach all the relevant places about it. What does reverse-listing mean as well? reverse-listing is what src/backend/utils/adt/ruleutils.c does: produce something readable from an internal node tree. \d for a view, pg_dump, and other useful things depend on this. regards, tom lane ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
[HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Hi all, I've attached a patch for doing BETWEEN SYM/ASYM, however it just doesn't work!!! test=# select 2 between 1 and 3; ?column? -- t (1 row) test=# select 2 between 3 and 1; ?column? -- f (1 row) test=# select 2 between symmetric 3 and 1; ERROR: parser: parse error at or near 3 test=# select 2 between asymmetric 3 and 1; ERROR: parser: parse error at or near 3 test=# select 2 not between 3 and 1; ?column? -- t (1 row) test=# select 2 not between symmetric 3 and 1; ERROR: parser: parse error at or near 3 Can anyone see what's wrong? Chris Index: src/backend/parser/gram.y === RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v retrieving revision 2.301 diff -c -r2.301 gram.y *** src/backend/parser/gram.y 2002/04/09 20:35:51 2.301 --- src/backend/parser/gram.y 2002/04/10 02:58:38 *** *** 346,352 IMMEDIATE, INITIALLY, INOUT, OFF, OUT, PATH_P, PENDANT, ! REPLACE, RESTRICT, TRIGGER, WITHOUT --- 346,352 IMMEDIATE, INITIALLY, INOUT, OFF, OUT, PATH_P, PENDANT, ! REPLACE, RESTRICT, SYMMETRIC, ASYMMETRIC, TRIGGER, WITHOUT *** *** 4916,4923 | a_expr BETWEEN b_expr AND b_expr %prec BETWEEN { $$ = makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $3), ! makeA_Expr(OP, =, $1, $5)); } | a_expr NOT BETWEEN b_expr AND b_expr %prec BETWEEN { --- 4916,4942 | a_expr BETWEEN b_expr AND b_expr %prec BETWEEN { $$ = makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $3), ! makeA_Expr(OP, =, $1, $5)); ! ! } ! | a_expr BETWEEN ASYMMETRIC b_expr AND b_expr %prec BETWEEN ! { ! $$ = makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $4), ! makeA_Expr(OP, =, $1, $6)); ! ! } ! | a_expr BETWEEN SYMMETRIC b_expr AND b_expr%prec BETWEEN ! { ! $$ = makeA_Expr(OR, NULL, ! makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $4), ! makeA_Expr(OP, =, $1, $6)), ! makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $6), ! makeA_Expr(OP, =, $1, $4)) ! ); } | a_expr NOT BETWEEN b_expr AND b_expr %prec BETWEEN { *** *** 4925,4930 --- 4944,4966 makeA_Expr(OP, , $1, $4), makeA_Expr(OP, , $1, $6)); } + | a_expr NOT BETWEEN ASYMMETRIC b_expr AND b_expr %prec +BETWEEN + { + $$ = makeA_Expr(OR, NULL, + makeA_Expr(OP, , $1, $5), + makeA_Expr(OP, , $1, $7)); + } + | a_expr NOT BETWEEN SYMMETRIC b_expr AND b_expr%prec +BETWEEN + { + $$ = makeA_Expr(AND, NULL, + makeA_Expr(OR, NULL, + makeA_Expr(OP, , $1, $5), + makeA_Expr(OP, , $1, $7)), + makeA_Expr(OR, NULL, + makeA_Expr(OP, , $1, $7), + makeA_Expr(OP, , $1, $5)) + ); + } | a_expr IN in_expr {
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
On Wed, 10 Apr 2002, Christopher Kings-Lynne wrote: Hi all, I've attached a patch for doing BETWEEN SYM/ASYM, however it just doesn't work!!! test=# select 2 between 1 and 3; ?column? -- t (1 row) test=# select 2 between 3 and 1; ?column? -- f (1 row) test=# select 2 between symmetric 3 and 1; ERROR: parser: parse error at or near 3 test=# select 2 between asymmetric 3 and 1; ERROR: parser: parse error at or near 3 Chris, You seem to have forgotten to update keywords.c. Gavin ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Chris, You seem to have forgotten to update keywords.c. OK - works perfectly now :) Now I'm going to play with making the SYMMERIC and ASYMMETRIC keywords less reserved... Can someone comment on my use of %prec BETWEEN? Is that still correct now that we have the extra BETWEEN forms? Chris ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
On Wed, 10 Apr 2002, Christopher Kings-Lynne wrote: Chris, You seem to have forgotten to update keywords.c. OK - works perfectly now :) Now I'm going to play with making the SYMMERIC and ASYMMETRIC keywords less reserved... Can someone comment on my use of %prec BETWEEN? Is that still correct now that we have the extra BETWEEN forms? Yes. Have a look at the precedence table near the top of gram.y: %left UNION EXCEPT %left INTERSECT %left JOIN UNIONJOIN CROSS LEFT FULL RIGHT INNER_P NATURAL %left OR %left AND %right NOT %right '=' %nonassoc '' '' %nonassoc LIKE ILIKE %nonassoc ESCAPE %nonassoc OVERLAPS %nonassoc BETWEEN %nonassoc IN %left POSTFIXOP /* dummy for postfix Op rules */ [...] This is the order of precedence for rules which contain these operators. For example, if an expression contains: a AND b AND c it is evaluated as: ((a AND b) AND c) On the other hand: a OR b AND c is evaluated as: ((a OR b) AND c) since OR has a lower order of precedence. Now, consider: select 2 between asymmetric 3 and 1 Without the %prec BETWEEN 3 and 1 is given precedence over between. This will break your code. Gavin ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: Can someone comment on my use of %prec BETWEEN? Is that still correct now that we have the extra BETWEEN forms? Looks fine. AFAICS we want all these forms to have the binding precedence assigned to BETWEEN. If you don't do the %prec thing then the productions will have the precedence of their rightmost terminal symbol, ie, AND, ie, wrong. regards, tom lane ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: Can someone comment on my use of %prec BETWEEN? Is that still correct now that we have the extra BETWEEN forms? Looks fine. AFAICS we want all these forms to have the binding precedence assigned to BETWEEN. If you don't do the %prec thing then the productions will have the precedence of their rightmost terminal symbol, ie, AND, ie, wrong. OK, I've proven that I cannot move the SYM/ASYM keywords anything lower than totally reserved without causing shift/reduce errors. Is this acceptable? Also, Tom (or anyone): in regards to your previous email, should I just go back to using opt_symmetry to shorten the number of productions, since I have to make them reserved words anyway? Chris ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
[HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Hi All, As part of my ongoing quest to understand grammar files, I've been trying to implement BETWEEN SYMMETRIC/ASYMMETRIC. I've attached my current work. Can someone please look and tell me if I'm on the right track? With this patch, I get parse errors after BETWEEN if I go: SELECT 2 BETWEEN ASYMMETRIC 1 and 3; or SELECT 2 BETWEEN SYMMETRIC 1 and 3; So it doesn't seem to be working - I don't know why!! Don't look at the NOT BETWEEN stuff - I've not done it yet. I was forced to put SYMMETRIC and ASYMMETRIC as reserved words - anything else seemed to give shift/reduce errors. Is there anything I can do about that? Chris ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
*sigh* I actually attached the diff this time... Chris -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Christopher Kings-Lynne Sent: Wednesday, 3 April 2002 12:26 PM To: Hackers Subject: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC Hi All, As part of my ongoing quest to understand grammar files, I've been trying to implement BETWEEN SYMMETRIC/ASYMMETRIC. I've attached my current work. Can someone please look and tell me if I'm on the right track? With this patch, I get parse errors after BETWEEN if I go: SELECT 2 BETWEEN ASYMMETRIC 1 and 3; or SELECT 2 BETWEEN SYMMETRIC 1 and 3; So it doesn't seem to be working - I don't know why!! Don't look at the NOT BETWEEN stuff - I've not done it yet. I was forced to put SYMMETRIC and ASYMMETRIC as reserved words - anything else seemed to give shift/reduce errors. Is there anything I can do about that? Chris ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED]) Index: src/backend/parser/gram.y === RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v retrieving revision 2.299 diff -c -r2.299 gram.y *** src/backend/parser/gram.y 2002/04/01 04:35:38 2.299 --- src/backend/parser/gram.y 2002/04/03 04:21:13 *** *** 148,154 simple_select %type nodealter_column_default ! %type ivaldrop_behavior, opt_drop_behavior %type list createdb_opt_list, createdb_opt_item %type boolean opt_equal --- 148,154 simple_select %type nodealter_column_default ! %type ivaldrop_behavior, opt_drop_behavior, opt_asymmetry %type list createdb_opt_list, createdb_opt_item %type boolean opt_equal *** *** 344,350 IMMEDIATE, INITIALLY, INOUT, OFF, OUT, PATH_P, PENDANT, ! REPLACE, RESTRICT, TRIGGER, WITHOUT --- 344,350 IMMEDIATE, INITIALLY, INOUT, OFF, OUT, PATH_P, PENDANT, ! REPLACE, RESTRICT, SYMMETRIC, ASYMMETRIC, TRIGGER, WITHOUT *** *** 4948,4964 b-booltesttype = IS_NOT_UNKNOWN; $$ = (Node *)b; } ! | a_expr BETWEEN b_expr AND b_expr %prec BETWEEN { ! $$ = makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $3), ! makeA_Expr(OP, =, $1, $5)); } ! | a_expr NOT BETWEEN b_expr AND b_expr %prec BETWEEN { $$ = makeA_Expr(OR, NULL, ! makeA_Expr(OP, , $1, $4), ! makeA_Expr(OP, , $1, $6)); } | a_expr IN in_expr { --- 4948,4975 b-booltesttype = IS_NOT_UNKNOWN; $$ = (Node *)b; } ! | a_expr BETWEEN opt_asymmetry b_expr AND b_expr %prec BETWEEN { ! if ($3 == SYMMETRIC) ! $$ = makeA_Expr(OR, NULL, ! makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $4), ! makeA_Expr(OP, =, $1, $6)), ! makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $6), ! makeA_Expr(OP, =, $1, $4)) ! ); ! else ! $$ = makeA_Expr(AND, NULL, ! makeA_Expr(OP, =, $1, $4), ! makeA_Expr(OP, =, $1, $6)); ! } ! | a_expr NOT BETWEEN opt_asymmetry b_expr AND b_expr%prec BETWEEN { $$ = makeA_Expr(OR, NULL
Re: [HACKERS] BETWEEN SYMMETRIC/ASYMMETRIC
Christopher Kings-Lynne [EMAIL PROTECTED] writes: I was forced to put SYMMETRIC and ASYMMETRIC as reserved words - anything else seemed to give shift/reduce errors. Is there anything I can do about that? First thought is don't try to be cute: forget the opt_asymmetry clause, and instead spell out six productions a_expr BETWEEN b_expr AND b_expr a_expr NOT BETWEEN b_expr AND b_expr a_expr BETWEEN SYMMETRIC b_expr AND b_expr a_expr NOT BETWEEN SYMMETRIC b_expr AND b_expr a_expr BETWEEN ASYMMETRIC b_expr AND b_expr a_expr NOT BETWEEN ASYMMETRIC b_expr AND b_expr I have not checked that this will work, but usually the cure for parse conflicts is to postpone the decision about which production applies. The reason opt_asymmetry forces SYMMETRIC and ASYMMETRIC to become reserved is that it requires a premature decision. Given, say a_expr BETWEEN . SYMMETRIC (where . means where we are now and SYMMETRIC is the current lookahead token), an LR(1) parser *must* decide whether to reduce opt_asymmetry as null, or to shift (implying that opt_asymmetry will be SYMMETRIC); it has to make this choice before it can look beyond the SYMMETRIC token. If SYMMETRIC might be a regular identifier then this is unresolvable without more lookahead. The six-production approach avoids this problem by not requiring any shift/reduce decisions to be made until an entire clause is available. On second thought there may be no other way out. Consider foo BETWEEN SYMMETRIC - bar AND baz Is SYMMETRIC a keyword (with - a prefix operator) or an identifier (with - infix)? This example makes me think that SYMMETRIC has to become reserved. But I wanted to point out that opt_asymmetry is certainly a loser based on lookahead distance. regards, tom lane ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
[HACKERS] BETWEEN [SYMMETRIC | ASYMMETRIC]
Here is current cvs: SELECT 2 BETWEEN 1 AND 3; ?column? -- t (1 row) subselects=# SELECT 2 BETWEEN 3 AND 1; ?column? -- f (1 row) Any chance of BETWEEN [SYMMETRIC | ASYMMETRIC] being implemented? SELECT 2 BETWEEN SYMMETRIC 3 AND 1; ?column? -- t (1 row) ASYMMETRIC is the default and what is currently the case. This would probably be easy TODO. -- Robert B. Easter [EMAIL PROTECTED] - -- CompTechNews Message Board http://www.comptechnews.com/ -- -- CompTechServ Tech Services http://www.comptechserv.com/ -- -- http://www.comptechnews.com/~reaster/
Re: [HACKERS] BETWEEN [SYMMETRIC | ASYMMETRIC]
"Robert B. Easter" [EMAIL PROTECTED] writes: subselects=# SELECT 2 BETWEEN 3 AND 1; ?column? -- f (1 row) SQL92 quoth: 6) "X BETWEEN Y AND Z" is equivalent to "X=Y AND X=Z". so this is correct behavior, even if it might seem surprising. Any chance of BETWEEN [SYMMETRIC | ASYMMETRIC] being implemented? SELECT 2 BETWEEN SYMMETRIC 3 AND 1; ?column? -- t (1 row) Build a function based on this idea: regression-# select case regression-# when 3 1 then 2 between 3 and 1 regression-# else 2 between 1 and 3 regression-# end; case -- t (1 row) I don't really see this as important enough to justify introducing a nonstandard syntax for it... regards, tom lane
Re: [HACKERS] BETWEEN [SYMMETRIC | ASYMMETRIC]
I don't really see this as important enough to justify introducing a nonstandard syntax for it... regards, tom lane Sorry to quote like this, it makes me feel like a real nerd. :) This quote from the SQL standard (1999) has it: 8.3 between predicate Function Specify a range comparison. Format between predicate ::= row value expression [ NOT ] BETWEEN [ ASYMMETRIC | SYMMETRIC ] row value expression AND row value expression Syntax Rules 1) If neither SYMMETRIC nor ASYMMETRIC is specified, then ASYMMETRIC is implicit. 2) Let X, Y, and Z be the first, second, and third row value expressions, respectively. 3) "X NOT BETWEEN SYMMETRIC Y AND Z" is equivalent to "NOT ( X BETWEEN SYMMETRIC Y AND Z )". 4) "X BETWEEN SYMMETRIC Y AND Z" is equivalent to "((X BETWEEN ASYMMETRIC Y AND Z) OR (X BETWEEN ASYMMETRIC Z AND Y))". 5) "X NOT BETWEEN ASYMMETRIC Y AND Z" is equivalent to "NOT ( X BETWEEN ASYMMETRIC Y AND Z )". 6) "X BETWEEN ASYMMETRIC Y AND Z" is equivalent to "X=Y AND X=Z". Access Rules None. General Rules None. Conformance Rules 1) Without Feature T461, "Symmetric between predicate", conforming SQL language shall not specify SYMMETRIC or ASYMMETRIC. 2) Without Feature S024, "Enhanced structured types", no subfield of the declared type of a row value expression that is simply contained in a between predicate shall be of a structured type. -- Robert B. Easter [EMAIL PROTECTED] - -- CompTechNews Message Board http://www.comptechnews.com/ -- -- CompTechServ Tech Services http://www.comptechserv.com/ -- -- http://www.comptechnews.com/~reaster/