-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: incompatible array type names in pg_type (Npgsql support) #13470
Comments
Great to see @jordanlewis! Another issue I just stumbled into, is that the I realize that making CockroachDB 100% compatible with PostgreSQL is a lot of work, although I think once we get past the type loading phase things should be fine. FYI, below is the query Npgsql executes in order to load types when first connecting to a database. Some of it is totally irrelevant for you guys (loading ranges, enums, composites), and I don't think you're far off from this actually working. Please let me know how I can help further. SELECT ns.nspname, a.typname, a.oid, a.typrelid, a.typbasetype,
CASE WHEN pg_proc.proname='array_recv' THEN 'a' ELSE a.typtype END AS type,
CASE
WHEN pg_proc.proname='array_recv' THEN a.typelem
WHEN a.typtype='r' THEN rngsubtype
ELSE 0
END AS elemoid,
CASE
WHEN pg_proc.proname IN ('array_recv','oidvectorrecv') THEN 3 /* Arrays last */
WHEN a.typtype='r' THEN 2 /* Ranges before */
WHEN a.typtype='d' THEN 1 /* Domains before */
ELSE 0 /* Base types first */
END AS ord
FROM pg_type AS a
JOIN pg_namespace AS ns ON (ns.oid = a.typnamespace)
JOIN pg_proc ON pg_proc.oid = a.typreceive
LEFT OUTER JOIN pg_type AS b ON (b.oid = a.typelem)
LEFT OUTER JOIN pg_range ON (pg_range.rngtypid = a.oid)
WHERE
(
a.typtype IN ('b', 'r', 'e', 'd') AND
(b.typtype IS NULL OR b.typtype IN ('b', 'r', 'e', 'd')) /* Either non-array or array of supported element type */
) OR
(a.typname IN ('record', 'void') AND a.typtype = 'p')
ORDER BY ord |
Ah, yeah. We provide minimal support for the Thanks for the report - we can do the same thing here. Boy, wouldn't it be nice if |
That method would exclude the |
@jordanlewis the Unfortunately this whole area is a bit messy, and suffers from some backwards-compatibility constraints. IMHO the most natural thing would have been for |
This is blocked on #13567 |
Not scheduled for 1.0 (but may happen depending on other work) |
A similar issue happened to me when trying to use Microsoft Power BI with npgsql. Details: "An error happened while reading data from the provider: 'The field 'TABLE_SCHEMA' has a type currently unknown to Npgsql (OID 25). You can retrieve it as a string by marking it as unknown, please see the FAQ.' I guess this is not something you can fix, but it may be good to know. |
Closing this issue, if there are any issues, please reopen or create a new issue. |
Continuing attempts to get Npgsql (.NET PostgreSQL driver) to work with CockroachDB (#9955), we can now connect to the database but can't transfer any types.
The reason is that type names in pg_type have names which have nothing to do with the standard names in PostgreSQL. For example, while PostgreSQL has types int2 (oid 21), int4 (oid 23), int8 (oid 20), in Cockroach all these types have the name int.
To clarify, it seems that most database drivers contains a simple, hardcoded list of OIDs which they recognize. Npgsql, however, queries pg_type upon first connecting and maps by type names - it looks for int4 (not int) and gets its OID.
It could be argued that Npgsql should also load by OIDs (or at least provide an option to do so), but you guys seem to want to be as PostgreSQL-compatible as possible (otherwise you wouldn't have implemented pg_type in the first place). May I suggest you synchronize your pg_type with PostgreSQL as much as possible?
Once this is done I'll be happy to continue testing Npgsql and reporting issues, to the point where you can list it as a compatible driver for C#/.NET.
Jira issue: CRDB-14703
Jira issue: CRDB-14705
The text was updated successfully, but these errors were encountered: