Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The D6 pgsql driver does not properly created unsigned numeric fields if the schema so specifies. I've attached a patch for D6. It applies to D7 as well. However, it also needs to be applied to the PDO changes in progress, so this issue should not be closed until it is in all three places.
Comment | File | Size | Author |
---|---|---|---|
#25 | system.install-256001-25_D6.patch | 1.88 KB | Darren Oh |
#22 | system.install-256001-22_D6.patch | 2.27 KB | Darren Oh |
#20 | pgsql-unsigned.D6.patch | 1.02 KB | stormsweeper |
#18 | pgsql-unsigned.D6.patch | 773 bytes | stormsweeper |
#17 | pgsql-unsigned.D6.patch | 4.07 KB | stormsweeper |
Comments
Comment #1
Dries CreditAttribution: Dries commentedI assume the changes to bootstrap.inc are "optional"? ;-)
Could you add a one-line code comment?
CHECK($name >= 0)
is new to me.Comment #2
bjaspan CreditAttribution: bjaspan commentedThe change to bootstrap is an accident. :-)
Comment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedSome discussion about this already occurred some years ago, in #60871.
Comment #4
bjaspan CreditAttribution: bjaspan commented@#3: Thanks for the pointer, I did not know about that issue.
New patch attached. Turns out D6 pgsql driver also does not support unsigned floats; also fixed.
Comment #5
Dries CreditAttribution: Dries commentedI've committed this patch to CVS HEAD. Would be better if it came with tests.
Comment #6
bjaspan CreditAttribution: bjaspan commentedOkay, I'll mark it CNW pending tests.
Comment #7
bjaspan CreditAttribution: bjaspan commentedTests for signed/unsigned int, float, and numeric columns for HEAD. Remember to 'cvs add' this new file.
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedOn 7.x, this patch causes a lot of exceptions during testing:
I'm not sure if this is a simpletest / SchemaAPI bug or a bug with that patch.
Comment #9
bjaspan CreditAttribution: bjaspan commentedIt is not this patch that causes those exceptions; every test on pgsql throws those exceptions with or without this patch.
See http://drupal.org/node/257009 which fixes simpletest for pgsql.
Comment #10
elyobo CreditAttribution: elyobo commentedCan I ask how this is coming along? I just ran into the same problem installing the development version of Ubercart with D6.4. The fix looks trivial, is there some holdup?
Comment #11
linuxpoet CreditAttribution: linuxpoet commentedI am having problems determining what the actual problem here is. The errors listed on the page are obvious, it can't create the type because the type already exists. What is the actual problem?
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedIf this works for 6.x, I'd ask that it be implemented, and that development to fix the issues in 7.x be continued separately.
A lot of people are using 6.x now, and this is bug prohibits some of us from using certain modules (for example, the Amazon module).
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedThe last submitted patch failed testing.
Comment #14
Damien Tournoud CreditAttribution: Damien Tournoud commentedWere duplicates:
#334791: PostgreSQL not handling unsigned properly
#334794: PostgreSQL not handling unsigned properly
#334598: PostgreSQL not handling unsigned properly
Comment #15
linuxpoet CreditAttribution: linuxpoet commentedI repeat the assertion tha this is a no-op problem. The errors that people mentioned are because the types already existed and it looks as if it has been solved in other tickets. I am going to close this ticket. Please re-open with an actual problem if there is one :)
Comment #16
linuxpoet CreditAttribution: linuxpoet commentedComment #17
stormsweeper CreditAttribution: stormsweeper commentedIn D7, DBTNG apparently fixes this by adding in CHECK constraints instead of the D5/D6 solution of creating domains.
D5/D6 uses domains for the int types, but this won't work for numeric, since the precision and scale parameters need to be defined when the domain is created. I'd support back-porting the D7 solution as with schema api there isn't really any worry of breaking extant modules. The serial type is already handled this way.
The patch attached just changes the PGSQL driver function that generates the SQL for field definitions. It could be extended to take out the domain creation in system_install, although you would not want to drop the domains.
Comment #18
stormsweeper CreditAttribution: stormsweeper commentedThe latest offender here is the Twitter module, which just changed it's primary key to numeric from int. On Postgres, this severely borks your table on update.
Also, please use this patch. I accidentally did not revert some other edits I was working on.
Comment #19
stormsweeper CreditAttribution: stormsweeper commentedBetter yet, use this one. I had to move the unsigned bit after the length/precision bit. Going to file a new issue for D7, since the same error exists there.
Comment #20
stormsweeper CreditAttribution: stormsweeper commentedMight help if I included the patch.
Comment #21
stormsweeper CreditAttribution: stormsweeper commentedD7 patch here: #522786: Postgres numeric check needs to happen after precision check in schema generation
Comment #22
Darren OhUnsigned types are added to PostgreSQL during installation. The problem is that some are missing. Thanks to ccurvey for pointing this out in issue 359764.
Comment #23
shunting CreditAttribution: shunting commentedAs a PG lurker, let me thank you all for doing this. It's been a constant source of frustration (and a source of secret shame to me when I hack install files and the odd function or two)...
Comment #24
stormsweeper CreditAttribution: stormsweeper commentedDarren, you can't specify precision, length, or scale for domains after they are created, ie,
Will barf.
Comment #25
Darren OhThanks.
Comment #26
stormsweeper CreditAttribution: stormsweeper commentedNow we're back to this issue's original post - the unsigned numeric type (specified in schema api) can't be created.
Also, I still think domains are an anti-pattern we don't need to use, and in fact are not used in D7. I presume the argument for them in D4 and D5 was to offer types that made it easier for people to just copy over mySql schema definitions, rather than using the CHECK clause in the column definition directly. I think we should just check for the unsigned flag on the appropriate types and add the CHECK clause rather than adding a bunch of domains and special casing things.
Comment #27
stormsweeper CreditAttribution: stormsweeper commentedAs a side point, the use of a CHECK clause is likely pointless since the unsigned types seem to be used in Drupal for the expanded range of values, which you don't get with Postgres and a CHECK clause. You could bump unsigned int to bigint, but that would leave you without any recourse for bigints except to then switch to a numeric column. Messy.
Comment #28
Darren OhThe patch in #20 works.
Comment #29
Gábor Hojtsy#522786: Postgres numeric check needs to happen after precision check in schema generation is the very same patch as #20 is here (but with added tests), so marking postponed on that one getting into Drupal 7. I'm not supposed to commit changes before they land in D7, unless they do not apply to D7. As soon as that one is committed, please reopen this.
Comment #30
webchickThe other patch has been committed. Moving back to RTBC.
Comment #31
webchickWell... hold that thought. :P The 7.x patch caused test failures, so I had to roll it back. Hopefully will be a quick fix.
Comment #32
TR CreditAttribution: TR commentedMoving back to RTBC again since webchick re-committed the 7.x patch (http://drupal.org/node/522786#comment-2573732) and #522786: Postgres numeric check needs to happen after precision check in schema generation is now marked as "fixed".
Comment #33
andypostwhat status of this issue?
Comment #34
Anonymous (not verified) CreditAttribution: Anonymous commented#522786: Postgres numeric check needs to happen after precision check in schema generation is committed - can we get this one committed too?
Comment #35
esteewhy CreditAttribution: esteewhy commentedpgsql-numeric-unsigned.patch queued for re-testing.
Comment #36
Gábor HojtsyCommitted, thank you.