-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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] SELECTing directly from a sequence throws an error #999
Comments
This could be lower-pri, right? I am not sure if this is a common flow. Most apps would do |
Correct. But I'm just trying to open bugs for all the issues I know that are related to sequences. For now we will improve the error message to let the user know that we don't support selecting from sequences directly instead of throwing some error directly from catalog_manager.cc. The disadvantage of using nextval() is that it increments the last_value. |
makes sense @hectorgcr . |
Summary: Currently we get this error: ``` CREATE SEQUENCE postgres=# select last_value from s; ERROR: Not found: Error loading table with id 000047c5000030008000000000006710: Not found (yb/master/catalog_manager.cc:3398): The table does not exist: table_id: "000047c5000030008000000000006710"``` Changing the code to give a more informative error ```ERROR: "s" is a sequence table DETAIL: Querying sequence tables is not supported yet. HINT: Use lastval() and currval().``` Test Plan: New unit test Reviewers: mihnea, robert Reviewed By: robert Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D6333
@ndeodhar found that pg_dump doesn't work correctly for sequences because it is trying to do a SELECT on the sequence:
|
Another thing to verify: Since we create a separate postgres table for sequence, it's likely that pg_dump will add a "create table" statement for that sequence table. This may cause issues while loading the data. |
Summary: It is now possible to do SELECT statements on sequences, which was formerly impossible because the data from all sequences was stored in a single YugaByte table rather than each sequence having their own table as PostgreSQL expects. To simulate the expected behavior, when Postgres attempts to read a data page from the sequence, a blank data page is allocated and filled with the data that is read from YugaByte. Test Plan: In `ysqlsh`, create a sequence (`CREATE SEQUENCE seq`) and select from it (`SELECT * FROM seq`). There should be three columns returned: `last_value`, `log_cnt`, and `is_called`. It should start with `last_value` as 1. Do something like `SELECT nextval('seq')` to increment the sequence and then perform another `SELECT` to ensure that `last_value` was appropriately incremented that same number of times. Reviewers: kannan, hector, neha Reviewed By: hector, neha Subscribers: yql Differential Revision: https://phabricator.dev.yugabyte.com/D6841
Currently we don't support selecting directly from a sequence:
The text was updated successfully, but these errors were encountered: