You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sqlc currently errors out with column "…" does not exist when referencing a PostgreSQL system column (tableoid, xmin, cmin, xmax, cmax or ctid) in an SQL query.
There was already a pull request that should fix this. And there are tests to make sure this is working. See here 1745
In this thread, there was a comment, that its not working with 1.25. Sadly its also not working with 1.27. And if you change the version to 1.23 in the playground, its also not working.
Relevant log output
query.sql:2:8: column "xmin" does not exist
Database schema
CREATETABLEauthors (
id BIGSERIALPRIMARY KEY,
name textNOT NULL,
bio text
);
after spending some time looking into the problem, I tested it using sql.database.managed set to true, and it's working. turns out that the pg config Analyzer is doing the job of getting pg system columns, and with default config of sql.database.managed set to false, then the pg config Analyzer is not initialized since there is no db to look for system columns. the solution (maybe) is to set list of hardcoded system columns if pg config Analyzer is not set, what do you think?
I do not know enough about the code architecture of sqlc to suggest something. The managed database feature is not working on my use cases, because the code is generated via a pipeline that has no access to a running database instance.
It is possible to configure something but it would be better if this feature is fully supported by sqlc. I think it's part of the syntax of postgres, so adding the system columns hardcoded seems absolutely fine.
Activity
swallowstalker commentedon Dec 23, 2024
after spending some time looking into the problem, I tested it using
sql.database.managedset totrue, and it's working. turns out that the pg config Analyzer is doing the job of getting pg system columns, and with default config ofsql.database.managedset tofalse, then the pg config Analyzer is not initialized since there is no db to look for system columns. the solution (maybe) is to set list of hardcoded system columns if pg config Analyzer is not set, what do you think?related docs
example config file
werjo-gridfuse commentedon Jan 6, 2025
I do not know enough about the code architecture of sqlc to suggest something. The managed database feature is not working on my use cases, because the code is generated via a pipeline that has no access to a running database instance.
It is possible to configure something but it would be better if this feature is fully supported by sqlc. I think it's part of the syntax of postgres, so adding the system columns hardcoded seems absolutely fine.
DenyVeyten commentedon Sep 13, 2025
Running into the same problem, PostgreSQL has a predefined list of system columns that ideally should be statically known to sqlc.