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

Diff breaks with error if custom collation exists at database side (~pg16). #1858

Open
tanzanite777 opened this issue Feb 29, 2024 · 1 comment

Comments

@tanzanite777
Copy link

Bug description
Description in title. Same bug is present in pgModeler 1.0.1 also. Seems to work with pg14.

How to reproduce
Create a typical collation:
CREATE COLLATION fwnumeric (provider = icu, locale = 'et-u-kn-true');

Diff against that schema in postgres ~16 and get error (see stacktrace).

Expected behavior
No errors.

Info about your desktop

  • pgModeler version: 1.1.0
  • pg that worked: PostgreSQL 14.1, compiled by Visual C++ build 1914, 64-bit
  • pg that bugged out: PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

Bugged out also with an earlier postgres, but did not note the version down - was probably 15-something.

Stacktrace / Debug info
Info in the error message do not make any sense to me (but i have a good guess - see "additional information section") - so, copy-paste here in full:

[0] src/tools/modeldatabasediffform.cpp (893)
  void ModelDatabaseDiffForm::captureThreadError(Exception)
    [ObjectNotImported] The object `public.fwnumeric' (Collation), oid `16427', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system/extension objects.

[1] src/tools/databaseimporthelper.cpp (705)
  void DatabaseImportHelper::importDatabase()
    [ObjectNotImported] The object `public.fwnumeric' (Collation), oid `16427', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system/extension objects.

[2] src/tools/databaseimporthelper.cpp (448)
  void DatabaseImportHelper::createObjects()
    [ObjectNotImported] The object `public.fwnumeric' (Collation), oid `16427', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system/extension objects.

[3] src/tools/databaseimporthelper.cpp (429)
  void DatabaseImportHelper::createObjects()
    [ObjectNotImported] The object `public.fwnumeric' (Collation), oid `16427', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system/extension objects.
       ** -- Raw attributes: fwnumeric (OID: 16427) --
comment: 
deterministic: true
encoding: 
lc-collate: 
lc-collate-mod: 
lc-ctype: 
lc-ctype-mod: 
name: fwnumeric
object-type: 22
oid: 16427
owner: 	<role name="bibis2_www"/>

permission: 
pgsql-ver: 16.0
provider: icu
schema: 	<schema name="public"/>

schema-oid: 2200
sql-disabled: 
---


[4] src/tools/databaseimporthelper.cpp (823)
  void DatabaseImportHelper::createObject(attribs_map&)
    [ObjectNotImported] The object `public.fwnumeric' (Collation), oid `16427', could not be imported due to one or more errors! Check the exception stack for more details. `HINT:' if the object somehow references objects in `pg_catalog' or `information_schema' consider enable the importing of system/extension objects.
       ** -- Raw attributes: fwnumeric (OID: 16427) --
comment: 
deterministic: true
encoding: 
lc-collate: 
lc-collate-mod: 
lc-ctype: 
lc-ctype-mod: 
name: fwnumeric
object-type: 22
oid: 16427
owner: 	<role name="bibis2_www"/>

permission: 
pgsql-ver: 16.0
provider: icu
schema: 	<schema name="public"/>

schema-oid: 2200
sql-disabled: 
---


[5] src/tools/databaseimporthelper.cpp (1543)
  void DatabaseImportHelper::createCollation(attribs_map&)
    [EmptyLCCollationAttributes] Collations must be created at least with attributes LC_COLLATE and LC_CTYPE defined!
       ** <collation name="fwnumeric" provider="icu" deterministic="true">
	<schema name="public"/>
	<role name="bibis2_www"/>
</collation>

[6] src/databasemodel.cpp (958)
  void DatabaseModel::addCollation(Collation*, int)
    [EmptyLCCollationAttributes] Collations must be created at least with attributes LC_COLLATE and LC_CTYPE defined!

[7] src/databasemodel.cpp (471)
  void DatabaseModel::__addObject(BaseObject*, int)
    [EmptyLCCollationAttributes] Collations must be created at least with attributes LC_COLLATE and LC_CTYPE defined!

[8] src/collation.cpp (182)
  virtual QString Collation::getSourceCode(SchemaParser::CodeType, bool)
    [EmptyLCCollationAttributes] Collations must be created at least with attributes LC_COLLATE and LC_CTYPE defined!

Additional info

Relevant pg_collation table row (which i believe pgModeler might be using) matching the collation creation SQL given in repro:

working (pg14): pg_collation { "oid": 36817, "collname": "fwnumeric", "collnamespace": 2200, "collowner": 10, "collprovider": "i", "collisdeterministic": "true", "collencoding": -1, "collcollate": "et-u-kn-true", "collctype": "et-u-kn-true", "collversion": "153.14.37" }
bugged (pg16): pg_collation { "oid": 224212, "collname": "fwnumeric", "collnamespace": 2200, "collowner": 16384, "collprovider": "i", "collisdeterministic": "true", "collencoding": -1, "collcollate": null, "collctype": null, "colliculocale": "et-u-kn", "collicurules": null, "collversion": "153.120.42" }

@rkhaotix rkhaotix added the bug label Feb 29, 2024
@rkhaotix
Copy link
Member

Thanks for reporting. I've identified the bug.

I'll create a quick fix for it on 1.1.1 to stop breaking the diff. But I'll have to make some refactoring in the collation object to make it compliant with PostgreSQL 16, which changed some aspects of collations. In that case, this patch will be only on 1.2.0-alpha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants