WD php: PDOException: SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation "clientside_validation_settings_clientside_validation_settings_f" [error]
already exists: CREATE INDEX "clientside_validation_settings_clientside_validation_settings_form_id_type_idx" ON {clientside_validation_settings}
("form_id", "type"); Array
(
)

Names in Postgres have a length limit, when installing the module, these limits get exhausted since the install creates indexes that are prefixed thus resulting in "clientside_validation_settings_clientside_validation_settings_f"

Omitting the additional prefix of the module name solves this issue, patch attached

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DrColossos’s picture

patches for 1.x and 2.x

DrColossos’s picture

forgot a change, re-attaching

DrColossos’s picture

Status: Active » Needs review
DrColossos’s picture

Issue summary: View changes
attiks’s picture

Status: Needs review » Needs work

Thanks for the patch, but we need an update function as well, can you add one?

DrColossos’s picture

sure, sorry for overlooking this. not used to do something in the _install hook

attiks’s picture

You need to add an update function, no need to change hook_install, see http://cgit.drupalcode.org/clientside_validation/tree/clientside_validat... for an example. So yours has to be named clientside_validation_update_7106

DrColossos’s picture

FileSize
2.94 KB

I know how they work, I just never wrote one ;) But thanks for the heads-up, appreciate it anways!

But here is the thing:

I have actually 2 indexes in my "clientside_validation_settings" table

  • clientside_validation_settings_clientside_validation_settings_f
  • clientside_validation_settings_clientside_validation_settings_t

Notice how "clientside_validation_settings_clientside_validation_settings_f" should actually be "clientside_validation_clientside_validation_settings_form_id" and "clientside_validation_clientside_validation_settings_form_id_type". This caused an error during install. I ignored this error since everything seemed to work fine.

Additionally, due the error, the system_version column inside the system table was not set. In my case, it looks like this

"sites/all/modules/clientside_validation/clientside_validation.module";"clientside_validation";"module";"''";1;0;-1;0;""

Notice the "-1"; this is the schema column. If I uninstall the module, delete the table from the database, make the schema changes from the previous patches, everything installs fine. The system.schema_version gets correctly set to 7005 as defined in your module.

I'm not sure, how to write the update hook since the system won't run my update hook. I attached a (pretty untested) patch, since I cannot run it with the default installation of it. I think this will work after the system.schema_version gets set properly. Not sure how to do this.

I'm happy to do the same for the 2.x branch after the problem with the system table has been cleared.

*update* I just changed the system.schema_version manually inside the database, and the update ran just fine. I now have the 3 indexes as supposed to.

attiks’s picture

Status: Needs work » Needs review

I'll try to review it tomorrow

Jibus’s picture

Encourting the same issue.

oliverde’s picture

having the same issue as well, patch works well

oliverde’s picture

FileSize
2.79 KB

Path in the patch was wrong fixed.

Juterpillar’s picture

Had the same issue. Thanks for the patch.

DrColossos’s picture

any progress on review?

ElusiveMind’s picture

I can confirm that the patch #12 does resolve the install issue with Postgres.

It's worth noting that this same issue exists in the 2.x branch of this module as well and will need to be addressed there as well.

ElusiveMind’s picture

Status: Needs review » Reviewed & tested by the community
nikunjkotecha’s picture

Status: Reviewed & tested by the community » Closed (outdated)

Did anyone get a chance to review this with module already installed? (verify the update hook)

I apologise for not pushing this right away, it is very old and I don't have the time or resources, there are no tests cases too to validate. I'll close as outdated for now but if someone working on a D7 site still can validate the update hook, please reopen with your findings and I'll merge if all good.