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

Incorrect DEFAULT values generated for Informix #15683

Closed
lukaseder opened this issue Oct 5, 2023 · 3 comments
Closed

Incorrect DEFAULT values generated for Informix #15683

lukaseder opened this issue Oct 5, 2023 · 3 comments

Comments

@lukaseder
Copy link
Member

Informix doesn't list DEFAULT values in SYSDEFAULTS that can be used right away, see:
https://www.ibm.com/support/pages/returning-literal-default-sysdefaults-default-column

For example:

select colname, coltype, default
from informix.syscolumns c
join informix.sysdefaults d
on c.tabid = d.tabid and c.colno = d.colno;

Resulting in:

|colname        |coltype|default                                                                                                                                                                                                                                                         |
|---------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|title          |269    |no title                                                                                                                                                                                                                                                        |
|language_id    |258    |AAAAAQ 1                                                                                                                                                                                                                                                        |
|obj_owner      |0      |informix                                                                                                                                                                                                                                                        |
|sequence       |2      |AAAAAA 0                                                                                                                                                                                                                                                        |
|obj_kind       |2      |AAAAAA 0                                                                                                                                                                                                                                                        |
|create_can_fail|41     |f                                                                                                                                                                                                                                                               |
|drop_can_fail  |41     |f                                                                                                                                                                                                                                                               |
|alter_can_fail |41     |f                                                                                                                                                                                                                                                               |
|state          |0      |U                                                                                                                                                                                                                                                               |
|temp_state     |0      |U                                                                                                                                                                                                                                                               |
|final_state    |0      |U                                                                                                                                                                                                                                                               |
|obj_kind       |2      |AAAAAA 0                                                                                                                                                                                                                                                        |
|obj_owner      |0      |informix                                                                                                                                                                                                                                                        |
|need_obj_kind  |2      |AAAAAA 0                                                                                                                                                                                                                                                        |
|need_obj_owner |0      |informix                                                                                                                                                                                                                                                        |
|state          |0      |U                                                                                                                                                                                                                                                               |
|temp_state     |0      |U                                                                                                                                                                                                                                                               |
|final_state    |0      |U                                                                                                                                                                                                                                                               |
|id             |258    |AAAAAQ 1                                                                                                                                                                                                                                                        |
|cd             |10     |                                                                                                                                                                                                                                                                |

This seems to be getting close:

select 
  colname, 
  coltype, 
  informix.schema_coltypename(coltype, extended_id),
  trim(CASE WHEN informix.schema_coltypename(coltype, extended_id) IN ('BOOLEAN', 'CHAR', 'VARCHAR', 'LVARCHAR') THEN default ELSE substr(default, instr(default, ' ')) END),
  default
from informix.syscolumns c
join informix.sysdefaults d
on c.tabid = d.tabid and c.colno = d.colno;

Resulting in:

|colname|coltype|(expression)      |(expression)      |default                                                                                                                                                                                                                                                         |
|-------|-------|------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|c1     |52     |BIGINT            |1                 |AAAAAAAAAAE 1                                                                                                                                                                                                                                                   |
|c2     |41     |BLOB              |                  |                                                                                                                                                                                                                                                                |
|c3     |41     |BOOLEAN           |t                 |t                                                                                                                                                                                                                                                               |
|c4     |11     |BYTE              |                  |                                                                                                                                                                                                                                                                |
|c5     |0      |CHAR              |c                 |c                                                                                                                                                                                                                                                               |
|c6     |7      |DATE              |2000-01-01        |AACOrQ 2000-01-01                                                                                                                                                                                                                                               |
|c8     |5      |DECIMAL           |1.1000000000000000|wQEKAAAAAAAAAA 1.1000000000000000                                                                                                                                                                                                                               |
|c9     |3      |FLOAT             |1.1000000000000000|mpmZmZmZ8T8 1.1000000000000000                                                                                                                                                                                                                                  |
|c10    |17     |INT8              |1                 |AAEAAAABAAAAAA 1                                                                                                                                                                                                                                                |
|c11    |2      |INTEGER           |1                 |AAAAAQ 1                                                                                                                                                                                                                                                        |
|c13    |40     |LVARCHAR          |v                 |v                                                                                                                                                                                                                                                               |
|c15    |4      |SMALLFLOAT        |1.10000000        |zcyMPw 1.10000000                                                                                                                                                                                                                                               |
|c16    |1      |SMALLINT          |1                 |AAE 1                                                                                                                                                                                                                                                           |
|c17    |12     |TEXT              |                  |                                                                                                                                                                                                                                                                |
|c18    |13     |VARCHAR           |v                 |v                                                                                                                                                                                                                                                               |
@lukaseder
Copy link
Member Author

This will be fixed in jOOQ 3.19.0 only, with #15682

3.19 Other improvements automation moved this from To do to Done Oct 5, 2023
lukaseder added a commit that referenced this issue Oct 5, 2023
…LT expression exists for DML

This includes:

- [#15683] Incorrect DEFAULT values generated for Informix
- [#15684] Add support for POSITION() in Informix via INSTR
@lukaseder
Copy link
Member Author

This issue shows that we're probably not getting DEFAULT values right for all data types and all RDBMS.

@lukaseder
Copy link
Member Author

Will soon create a follow-up issue to collect potential known problems in this area.

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

No branches or pull requests

1 participant