-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Unable to add new features in QGIS for PostGIS table using sequence for gid. Data type serial: 'integer overflow' #30041
Comments
Do you use QGIS 2.18 Las Palmas ? This version is not supported anymore. If so, please update to QGIS 3.x. Thanks |
I have one thing to add: it is the same behaviour with QGIS 3.x |
Checked, there is no way you can overflow serial, you should change type to bigserial or use an uuid. |
Re-opening for the NULL issue, the serial overflow is not a bug. |
Duplicate of #29489 |
Let me clarify my Problem: example with bug: CREATE TABLE myschema.mytable_bigserial SELECT 'myschema.mytable_bigserial'::regclass::oid;
|
@sylviaobk I cannot reproduce the issue (maybe because my table OID is much lower and it does not overflow) and I cannot just create 4 billion tables to make it overflow. |
Yes, me and my peers would test the patch!! Thank you :-) |
Ok, I was able to reproduce the issue on windows, reopening (again) |
@sylviaobk here is the test build http://www.itopen.it/bulk/qgis-mxe-release-2019-06-12-08-08-19.zip No installation required (unzip it somewhere and run qgis.exe), no Python. |
I ran \qgis-mxe-release-2019-06-12-08-08-19\qgis-mxe-release\qgis.exe, |
I think we have two different issues here:
I can reproduce issue 1 (using "serial") on both Linux and windows but as I said I don't think that is is a bug and we cannot do anything about it.
but my patch uses The default value that QGIS uses for
that is the next value of the sequence, if that overflows we are back to issue 1 and you should get an error message like (for type "serial")
Note also that if the table is created with "bigserial" a sequence with value 2147483647 will not overflow and the error 1 will not appear. |
QGIS was using int to store oids, but oids are 4 byte unsigned ints. This is an attempt to partially fix qgis#30041
I had high hopes your patch could fix the issue, and I don't understand why it doesn't. |
Just to be sure I fully understand your procedure, would you be able to share a short video of the operations that leads to the error? |
It is a mp4 file |
Are you missing the default value for gid?
|
Thank you, it is clear now. I'm looking for other OID overflows in the provider code now, I'll provide you a new version to test shortly. |
@sylviaobk some more fixes to the OIDs http://www.itopen.it/bulk/qgis-mxe-release-2019-06-12-14-02-44.zip please check it. |
That's it! :-) Thanks for your help! |
@sylviaobk , 2.18 is RIP, there's no way to overstate the need to move to the new LTR 3.4. If there are legitimate issues with 3.4 that prevents you from leading code of deceased 2.18, you should file tickets. |
So the bugfix would be implemented in LTR 3.4? |
@sylviaobk thank you for your help in identifying the root of the issue and for testing the patches, I will backport this into 3.4 branch and it will land into the LTR. |
PostGIS 2.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
Postgres PostgreSQL 9.5.4, compiled by Visual C++ build 1800, 64-bit
QGIS 2.18 Las Palmas
In QGIS I added the PostGIS - layer "myschema.mytable" and tried to save a new object.
Following message appears:
"Konnte Änderungen am Layer mytable nicht festschreiben
Fehler: FEHLER: Ein Objekt nicht hinzugefügt.
Datenanbieterfehler:
PostGIS-Fehler beim Attributhinzufügen: FEHLER: NULL-Wert in Spalte »gid«
verletzt Not-Null-Constraint
DETAIL: Fehlgeschlagene Zeile enthält (null,
0102000020E8640000020000004DAC4DB4A84918414C986446399155416E8719...)."
"Could not commit changes on layer mytable
Error: ERROR: One object is not added.
Data provider error:
PostGIS-Error on add attribute: ERROR: NULL- value in column »gid«
is not permitted as an input because of Not-Null-Constraint
DETAIL: Failed row contains (null,
0102000020E8640000020000004DAC4DB4A84918414C986446399155416E8719...)."
In QGIS should be the default for column 'gid':
nextval('myschema.mytable_gid_seq'::regclass)
Instead the default for column 'gid' is 'NULL'.
To reproduce the error select on PostGIS:
SELECT 'myschema.mytable'::regclass::oid;
If the result is bigger than the maximum integer - value 2147483647
it is not possible to use data type 'serial' in QGIS to add a new object.
But in PostGIS I can add objects if the value of column "gid" is of data type 'serial'
and the result is bigger than 2147483647 because PostGIS has no "integer overflow".
(Please refer to #29489, https://issues.qgis.org/issues/21673)
I think QGIS can't handle sequences after integer overflow.
Is it possible to change the data type of regclass::oid from 'integer' into 'biginteger'
in QGIS??
The text was updated successfully, but these errors were encountered: