patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Started by Robert B. Easterover 25 years ago11 messagespatches
Jump to latest
#1Robert B. Easter
reaster@comptechnews.com

This was a trivial thing to implement in the parser (unless I overlooked
something!). Please review it and let me know if I missed something. This
adds SQL-1999 BETWEEN [ASYMMETRIC|SYMMETRIC] language. Hopefully it's not
considered just SQL bloat. ;)

--
-------- Robert B. Easter reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

Attachments:

gram.y.patchtext/x-c; name=gram.y.patchDownload+36-3
keywords.c.patchtext/plain; name=keywords.c.patchDownload+2-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert B. Easter (#1)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

"Robert B. Easter" <reaster@comptechnews.com> writes:

This was a trivial thing to implement in the parser (unless I overlooked
something!). Please review it and let me know if I missed something.

ColId (or at least ColLabel) entries for the added keywords.

This doesn't strike me as a particularly efficient implementation,
but until there's a groundswell of actual use, maybe we don't care...

regards, tom lane

#3Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: Robert B. Easter (#1)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

This was a trivial thing to implement in the parser (unless I overlooked
something!). Please review it and let me know if I missed something. This
adds SQL-1999 BETWEEN [ASYMMETRIC|SYMMETRIC] language. Hopefully it's not
considered just SQL bloat. ;)

No more bloat than in the rest of the language ;)

I *assume* that this will have trouble making it in to 7.1, and since
keywords are likely added this may have trouble with 7.1.x (not sure
about that; perhaps the lex-generated token values never make it into
the database tables, but they *do* propagate into structures used deeper
in the backend).

- Thomas

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Lockhart (#3)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Thomas Lockhart <lockhart@alumni.caltech.edu> writes:

I *assume* that this will have trouble making it in to 7.1, and since
keywords are likely added this may have trouble with 7.1.x (not sure
about that; perhaps the lex-generated token values never make it into
the database tables, but they *do* propagate into structures used deeper
in the backend).

Since he didn't add a new parsetree node type, there wouldn't be any
database compatibility issue AFAIK. I'm pretty certain that keyword
token values never get into stored rules.

However, there is our self-imposed "no new features during beta" rule.
This looks like a relatively harmless patch, but do we want to break
that rule for something that people are not beating down our doors for?

I'd vote for holding it for 7.2, I think.

regards, tom lane

#5Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#4)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

I concur. about holding for 7.2. Though this is of limited danger, it
is not something that is really in hight demand.

Thomas Lockhart <lockhart@alumni.caltech.edu> writes:

I *assume* that this will have trouble making it in to 7.1, and since
keywords are likely added this may have trouble with 7.1.x (not sure
about that; perhaps the lex-generated token values never make it into
the database tables, but they *do* propagate into structures used deeper
in the backend).

Since he didn't add a new parsetree node type, there wouldn't be any
database compatibility issue AFAIK. I'm pretty certain that keyword
token values never get into stored rules.

However, there is our self-imposed "no new features during beta" rule.
This looks like a relatively harmless patch, but do we want to break
that rule for something that people are not beating down our doors for?

I'd vote for holding it for 7.2, I think.

regards, tom lane

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#6Bruce Momjian
bruce@momjian.us
In reply to: Robert B. Easter (#1)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Can someone comment on this?

[ Charset ISO-8859-1 unsupported, converting... ]

This was a trivial thing to implement in the parser (unless I overlooked
something!). Please review it and let me know if I missed something. This
adds SQL-1999 BETWEEN [ASYMMETRIC|SYMMETRIC] language. Hopefully it's not
considered just SQL bloat. ;)

--
-------- Robert B. Easter reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

[ Attachment, skipping... ]

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#6)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Can someone comment on this?

It's a new feature, so it should wait for 7.2 ...

In any case, there are further considerations here, like getting
ruleutils.c to reverse-list the construct correctly. When we
redesign querytree structures, reconstructability needs to be one
of the considerations.

regards, tom lane

#8Bruce Momjian
bruce@momjian.us
In reply to: Robert B. Easter (#1)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Robert, did we ever resolve if this is a valuable patch?

[ Charset ISO-8859-1 unsupported, converting... ]

This was a trivial thing to implement in the parser (unless I overlooked
something!). Please review it and let me know if I missed something. This
adds SQL-1999 BETWEEN [ASYMMETRIC|SYMMETRIC] language. Hopefully it's not
considered just SQL bloat. ;)

--
-------- Robert B. Easter reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

[ Attachment, skipping... ]

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#9Bruce Momjian
bruce@momjian.us
In reply to: Robert B. Easter (#1)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Can someone comment on where we left this?

This was a trivial thing to implement in the parser (unless I overlooked
something!). Please review it and let me know if I missed something. This
adds SQL-1999 BETWEEN [ASYMMETRIC|SYMMETRIC] language. Hopefully it's not
considered just SQL bloat. ;)

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

*** gram.y	Wed Jan 10 20:45:40 2001
--- gram.y.modi	Wed Jan 10 20:44:38 2001
***************
*** 321,332 ****
  		WHEN, WHERE, WITH, WORK, YEAR_P, ZONE

/* Keywords (in SQL3 reserved words) */
! %token CHAIN, CHARACTERISTICS,
DEFERRABLE, DEFERRED,
IMMEDIATE, INITIALLY, INOUT,
OFF, OUT,
PATH_P, PENDANT,
RESTRICT,
TRIGGER,
WITHOUT

--- 321,334 ----
  		WHEN, WHERE, WITH, WORK, YEAR_P, ZONE

/* Keywords (in SQL3 reserved words) */
! %token ASYMMETRIC,
! CHAIN, CHARACTERISTICS,
DEFERRABLE, DEFERRED,
IMMEDIATE, INITIALLY, INOUT,
OFF, OUT,
PATH_P, PENDANT,
RESTRICT,
+ SYMMETRIC,
TRIGGER,
WITHOUT

***************
*** 4452,4462 ****
--- 4454,4496 ----
  						makeA_Expr(OP, ">=", $1, $3),
  						makeA_Expr(OP, "<=", $1, $5));
  				}
+ 		| a_expr BETWEEN ASYMMETRIC b_expr AND b_expr
+ 				{
+ 					$$ = makeA_Expr(AND, NULL,
+ 						makeA_Expr(OP, ">=", $1, $4),
+ 						makeA_Expr(OP, "<=", $1, $6));
+ 				}
+ 		| a_expr BETWEEN SYMMETRIC b_expr AND b_expr
+ 				{
+ 					$$ = 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
  				{
  					$$ = makeA_Expr(OR, NULL,
  						makeA_Expr(OP, "<", $1, $4),
  						makeA_Expr(OP, ">", $1, $6));
+ 				}
+ 		| a_expr NOT BETWEEN ASYMMETRIC b_expr AND b_expr
+ 				{
+ 					$$ = makeA_Expr(OR, NULL,
+ 						makeA_Expr(OP, "<", $1, $5),
+ 						makeA_Expr(OP, ">", $1, $7));
+ 				}
+ 		| a_expr NOT BETWEEN SYMMETRIC b_expr AND b_expr
+ 				{
+ 					$$ = 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 ')'
  				{
-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#9)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Can someone comment on where we left this?

The grammar patch is incorrect/incomplete as given (no keywords.c
entries, no additions to the TokenId list), unless you quoted only
part of it.

More generally, I hate to see us yet again doing a quick shortcut that
loses information. BETWEEN really ought to be a 3-operand function or
special expression node type, so that it (a) can be reverse-listed
sensibly, and (b) doesn't result in multiple evaluations of its inputs.

regards, tom lane

#11Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#10)
Re: patch for BETWEEN [ASYMMETRIC|SYMMETRIC]

OK, patch rejected.

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Can someone comment on where we left this?

The grammar patch is incorrect/incomplete as given (no keywords.c
entries, no additions to the TokenId list), unless you quoted only
part of it.

More generally, I hate to see us yet again doing a quick shortcut that
loses information. BETWEEN really ought to be a 3-operand function or
special expression node type, so that it (a) can be reverse-listed
sensibly, and (b) doesn't result in multiple evaluations of its inputs.

regards, tom lane

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026