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

not compatible with PG when binding insert into table with generated column #17628

Open
st1page opened this issue Jul 9, 2024 · 0 comments
Open
Assignees
Milestone

Comments

@st1page
Copy link
Contributor

st1page commented Jul 9, 2024

In RisingWave, when inserting into a table with a generated column, RisingWave automatically removes the generated column during the insert column mapping. However, PostgreSQL does not do this.

pub fn columns_to_insert(&self) -> impl Iterator<Item = &ColumnCatalog> {
self.columns
.iter()
.filter(|c| !c.is_hidden() && !c.is_generated())
}

RW behavior:

dev=> create table t(v1 int, v2 int AS (v1+1), v3 int default 10);
CREATE_TABLE
dev=> insert into t values (0, 1);
INSERT 0 1
dev=> select * from t;
 v1 | v2 | v3 
----+----+----
  0 |  1 |  1

PG behavior: (PostgreSQL 16.2)

postgres=# create table t(v1 int, v2 int GENERATED ALWAYS AS (v1+1) STORED, v3 int default 10);
CREATE TABLE
postgres=# insert into t values (0, 1);
ERROR:  cannot insert a non-DEFAULT value into column "v2"
DETAIL:  Column "v2" is a generated column.
postgres=# insert into t(v1, v3) values (0, 1);
INSERT 0 1
postgres=# insert into t values (0, 1, 2);
ERROR:  cannot insert a non-DEFAULT value into column "v2"
DETAIL:  Column "v2" is a generated column.
@st1page st1page changed the title bug: not compatible with PG when binding insert into table with generated column not compatible with PG when binding insert into table with generated column Jul 9, 2024
@st1page st1page self-assigned this Jul 9, 2024
@github-actions github-actions bot added this to the release-1.10 milestone Jul 9, 2024
@st1page st1page modified the milestones: release-2.1, release-2.2 Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant