Spurious sytax error with INSERT

This forum is to report technical problems with Rel.
Post Reply
HughDarwen
Posts: 121
Joined: Sat May 24, 2008 4:49 pm

Spurious sytax error with INSERT

Post by HughDarwen » Mon Sep 09, 2019 4:53 pm

Try this:

var x base relation{z char} key{z};
insert x extend TABLE_DEE : {z := '//'};

I get
ERROR: Encountered "insert" at line 1, column 1.

Was expecting one of:
"BEGIN" ...
"TCLOSE" ...
<TUPLE> ...
"WITH" ...
<TUPLE> ...

I have used a bypass of this kind sometimes:

x := (extend TABLE_DEE : {z := '//'}) union x;

but it doesn't work with this particular example.

The problem seems to arise only with multiple successive slashes in quotes.

Hugh

Dave
Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: Spurious sytax error with INSERT

Post by Dave » Sat Sep 21, 2019 11:43 am

I'll do some tests on this to see if I can find a workaround. I know EXTEND can expose a grammar ambiguity (I don't recall the specifics, but I know it does) and this is likely related to it.

Dave
Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: Spurious sytax error with INSERT

Post by Dave » Sat Sep 21, 2019 12:20 pm

I see the problem -- it's with the mechanism in the DBrowser front-end that tries to detect whether you've entered an expression or one or more statements. It's surprisingly complex and it can be fooled. In this case, it's being fooled into thinking you've entered an expression by the slashes '//', which it thinks are a comment token and so it ignores the rest of the line.

A simple workaround is to force the front-end to treat your statement(s) as an expression, using a Rel extension for that purpose. You surround the statements with a BEGIN ... END block, followed by an expression. Like this:

Code: Select all

begin;
	var x base relation {z char} key {z};
	insert x extend TABLE_DEE : {z := '//'};
end;
true

HughDarwen
Posts: 121
Joined: Sat May 24, 2008 4:49 pm

Re: Spurious sytax error with INSERT

Post by HughDarwen » Sun Sep 22, 2019 2:11 pm

Thank you. I like your suggested bypass because since I posted this problem I've been surrounding the code with begin/end for other reasons. My own bypass had been to use direct assignment: x := (extend TABLE_DEE <etc.>) union x;

Hugh

Post Reply