Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Spurious "ERROR: 0A000: Alter table is not yet supported" from "create or replace view" #5071

Closed
bllewell opened this issue Jul 13, 2020 · 1 comment
Assignees
Labels
area/ysql Yugabyte SQL (YSQL)

Comments

@bllewell
Copy link
Contributor

bllewell commented Jul 13, 2020

Using YB-2.1.8.2-b0. Testcase:

\set VERBOSITY verbose
set client_min_messages = warning;
drop view if exists v;

create or replace view v as select 17 as c1;
select * from v;

create or replace view v as select 42 as c1;
select * from v;

The first create or replace view silently succeeds. But the second one causes this error:

0A000: Alter table is not yet supported

However, the select that immediately follows this reports 42. This shows that the view definition is in fact replaced.

So the error message is entirely spurious.

@bllewell bllewell added the area/ysql Yugabyte SQL (YSQL) label Jul 13, 2020
ramsrivatsa added a commit that referenced this issue Aug 28, 2020
…ng a pre-exiting view

Summary:
[YSQL] Spurious "ERROR: 0A000: Alter table is not yet supported" from "create or replace view" #5071

```
create or replace view v as select 17 as c1;
select * from v;
```

```
create or replace view v as select 42 as c1;
select * from v;
```
The first create or replace view silently succeeds. But the second one causes this error:

```
0A000: Alter table is not yet supported
```
However, the select that immediately follows this reports 42. This shows that the view definition is in fact replaced.

**FIX **
The fix to this problem is to simply disable checking the IsYugabyteEnabled() function to throw out this error.
The function which gets called is AlterTableInternal. The series of operations that happen while calling this function is similar to AlterTable. The main thing that should be noted here is towards inspecting different code paths where this functions is called and providing relevant unit tests to check whether it functionally executes what the user expects. This functional testing is covered in the unit tests.

Test Plan:
**Unit Tests**
To run unit tests to verify this change, the following java test can be utilized.

```
$HOME/code/devtools/bin/ybd --java-test org.yb.pgsql.TestPgRegressFeature
```

One of the sql files that it triggers is //yb_feature_alter_table.sql// where the SQL command tests different places in the code where //AlterTableInternal// is called.

1. Any create or replace  SQL command which modifies an existing view will call the //AlterTableInternal// function in line number 224 in //**view.c**//
2. When a create or replace view SQL modifies an existing view by adding additional columns to the view, //AlterTableInternal// in line number 192 at **//view.c//** is called in addition to the AlterTableInternal in line number 224 at **//view.c//**

The SQL tests as a part of this diff tests both functionality to check if they are working correctly.

Reviewers: alex, mihnea

Reviewed By: alex, mihnea

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D9259
@ramsrivatsa
Copy link
Contributor

Issue fixed with commit 3cbee16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL)
Projects
None yet
Development

No branches or pull requests

2 participants