IDEMPIERE-6064 Error when creating a table with a long name through CreateTable process (#2290)

* IDEMPIERE-6064: Error when creating a table with a long time through CreateTable process

* IDEMPIERE-6064: Error when creating a table with a long name through CreateTable process

* - set the length of tablename to 60 char, and other database object names to 63

* - minor javadoc clarification

* - Increase size of other columns and process parameters

* - fix wrong value for Old MAX_OBJECT_NAME_LENGTH

---------

Co-authored-by: Nicolas Micoud <58596990+nmicoud@users.noreply.github.com>
This commit is contained in:
Carlos Ruiz 2024-04-04 04:50:37 +02:00
parent 1a84a4029a
commit 5d04cc7728
8 changed files with 590 additions and 24 deletions

View File

@ -0,0 +1,272 @@
-- IDEMPIERE-6064 Error when creating a table with a long name through CreateTable process
SELECT register_migration_script('202404031226_IDEMPIERE-6064.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 3, 2024, 12:26:12 PM CEST
UPDATE AD_Column SET FieldLength=60, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:26:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=107
;
DROP INDEX AD_TABLE_NAME
;
-- Apr 3, 2024, 12:26:13 PM CEST
ALTER TABLE AD_Table MODIFY TableName VARCHAR2(60 CHAR)
;
CREATE UNIQUE INDEX AD_TABLE_NAME ON AD_TABLE (UPPER(TABLENAME))
;
-- Apr 3, 2024, 12:26:43 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:26:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=116
;
-- Apr 3, 2024, 12:27:50 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=20,Updated=TO_TIMESTAMP('2024-04-03 12:27:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210871
;
DROP INDEX AD_COLUMN_FKCONSTRAINTNAME
;
-- Apr 3, 2024, 12:27:55 PM CEST
ALTER TABLE AD_Column MODIFY FKConstraintName VARCHAR2(63 CHAR) DEFAULT NULL
;
CREATE UNIQUE INDEX AD_COLUMN_FKCONSTRAINTNAME ON AD_COLUMN (UPPER(FKCONSTRAINTNAME))
;
DROP INDEX AD_COLUMN_NAME
;
-- Apr 3, 2024, 12:28:10 PM CEST
ALTER TABLE AD_Column MODIFY ColumnName VARCHAR2(63 CHAR)
;
CREATE UNIQUE INDEX AD_COLUMN_NAME ON AD_COLUMN (AD_TABLE_ID, UPPER(COLUMNNAME))
;
-- Apr 3, 2024, 12:28:52 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:28:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2602
;
DROP INDEX AD_ELEMENT_UPPERCOLUMNNAME
;
-- Apr 3, 2024, 12:29:03 PM CEST
ALTER TABLE AD_Element MODIFY ColumnName VARCHAR2(63 CHAR)
;
CREATE UNIQUE INDEX AD_ELEMENT_UPPERCOLUMNNAME ON AD_ELEMENT (UPPER(COLUMNNAME))
;
-- Apr 3, 2024, 12:30:26 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:30:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210585
;
-- Apr 3, 2024, 12:30:27 PM CEST
ALTER TABLE AD_ViewColumn MODIFY ColumnName VARCHAR2(63 CHAR)
;
-- Apr 3, 2024, 12:30:46 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:30:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=202042
;
-- Apr 3, 2024, 12:30:47 PM CEST
ALTER TABLE WS_WebServiceFieldInput MODIFY ColumnName VARCHAR2(63 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 12:30:57 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:30:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208350
;
-- Apr 3, 2024, 12:30:58 PM CEST
ALTER TABLE AD_InfoColumn MODIFY ColumnName VARCHAR2(63 CHAR)
;
-- Apr 3, 2024, 12:31:30 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:31:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4017
;
-- Apr 3, 2024, 12:31:31 PM CEST
ALTER TABLE AD_Process_Para MODIFY ColumnName VARCHAR2(63 CHAR)
;
-- Apr 3, 2024, 12:32:06 PM CEST
UPDATE AD_Column SET FieldLength=60,Updated=TO_TIMESTAMP('2024-04-03 12:32:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213696
;
-- Apr 3, 2024, 12:32:08 PM CEST
ALTER TABLE AD_HouseKeeping MODIFY TableName VARCHAR2(60 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 12:33:04 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:33:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=216297
;
-- Apr 3, 2024, 12:33:12 PM CEST
ALTER TABLE AD_TablePartition MODIFY Name VARCHAR2(63 CHAR)
;
-- Apr 3, 2024, 12:33:30 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:33:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210522
;
DROP INDEX AD_TABLEINDEX_NAME
;
-- Apr 3, 2024, 12:33:31 PM CEST
ALTER TABLE AD_TableIndex MODIFY Name VARCHAR2(63 CHAR)
;
CREATE UNIQUE INDEX AD_TABLEINDEX_NAME ON AD_TABLEINDEX (UPPER(NAME))
;
-- Apr 3, 2024, 3:46:48 PM CEST
UPDATE AD_Process_Para SET FieldLength=60,Updated=TO_TIMESTAMP('2024-04-03 15:46:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53495
;
-- Apr 3, 2024, 3:46:58 PM CEST
UPDATE AD_Process_Para SET FieldLength=60,Updated=TO_TIMESTAMP('2024-04-03 15:46:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200354
;
-- Apr 3, 2024, 3:48:19 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 15:48:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11819
;
-- Apr 3, 2024, 3:48:27 PM CEST
ALTER TABLE A_RegistrationAttribute MODIFY ColumnName VARCHAR2(63 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:50:29 PM CEST
UPDATE AD_Process_Para SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 15:50:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200303
;
-- Apr 3, 2024, 3:51:50 PM CEST
UPDATE AD_Process_Para SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 15:51:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200306
;
-- Apr 3, 2024, 3:53:27 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:53:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5941
;
-- Apr 3, 2024, 3:53:36 PM CEST
ALTER TABLE PA_MeasureCalc MODIFY BPartnerColumn VARCHAR2(124 CHAR) DEFAULT 'x.C_BPartner_ID'
;
-- Apr 3, 2024, 3:54:01 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:54:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200528
;
-- Apr 3, 2024, 3:54:04 PM CEST
ALTER TABLE GL_JournalGeneratorLine MODIFY BPColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:54:20 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:54:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59701
;
-- Apr 3, 2024, 3:54:23 PM CEST
ALTER TABLE AD_ChartDatasource MODIFY CategoryColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:55:11 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:55:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=54272
;
-- Apr 3, 2024, 3:55:14 PM CEST
ALTER TABLE AD_Sequence MODIFY DateColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:55:24 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:55:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5939
;
-- Apr 3, 2024, 3:55:26 PM CEST
ALTER TABLE PA_MeasureCalc MODIFY DateColumn VARCHAR2(124 CHAR) DEFAULT 'x.Date'
;
-- Apr 3, 2024, 3:55:26 PM CEST
UPDATE PA_MeasureCalc SET DateColumn='x.Date' WHERE DateColumn IS NULL
;
-- Apr 3, 2024, 3:55:42 PM CEST
UPDATE AD_Column SET FieldLength=124, IsToolbarButton='N',Updated=TO_TIMESTAMP('2024-04-03 15:55:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59673
;
-- Apr 3, 2024, 3:55:44 PM CEST
ALTER TABLE AD_ChartDatasource MODIFY DateColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:56:13 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:56:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5662
;
-- Apr 3, 2024, 3:56:14 PM CEST
ALTER TABLE AD_ReportView_Col MODIFY FunctionColumn VARCHAR2(124 CHAR)
;
-- Apr 3, 2024, 3:56:37 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:56:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14780
;
-- Apr 3, 2024, 3:56:39 PM CEST
ALTER TABLE PA_MeasureCalc MODIFY KeyColumn VARCHAR2(124 CHAR)
;
-- Apr 3, 2024, 3:56:52 PM CEST
UPDATE AD_Column SET FieldLength=124, IsToolbarButton='N',Updated=TO_TIMESTAMP('2024-04-03 15:56:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59677
;
-- Apr 3, 2024, 3:56:54 PM CEST
ALTER TABLE AD_ChartDatasource MODIFY KeyColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:57:25 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:57:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200214
;
-- Apr 3, 2024, 3:57:26 PM CEST
ALTER TABLE AD_Sequence MODIFY OrgColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:57:35 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:57:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5940
;
-- Apr 3, 2024, 3:57:36 PM CEST
ALTER TABLE PA_MeasureCalc MODIFY OrgColumn VARCHAR2(124 CHAR) DEFAULT 'x.AD_Org_ID'
;
-- Apr 3, 2024, 3:57:36 PM CEST
UPDATE PA_MeasureCalc SET OrgColumn='x.AD_Org_ID' WHERE OrgColumn IS NULL
;
-- Apr 3, 2024, 3:57:36 PM CEST
ALTER TABLE PA_MeasureCalc MODIFY OrgColumn NOT NULL
;
-- Apr 3, 2024, 3:57:49 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:57:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5942
;
-- Apr 3, 2024, 3:57:51 PM CEST
ALTER TABLE PA_MeasureCalc MODIFY ProductColumn VARCHAR2(124 CHAR) DEFAULT 'x.M_Product_ID'
;
-- Apr 3, 2024, 3:58:03 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:58:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210647
;
-- Apr 3, 2024, 3:58:04 PM CEST
ALTER TABLE AD_ChartDatasource MODIFY SeriesColumn VARCHAR2(124 CHAR) DEFAULT NULL
;
-- Apr 3, 2024, 3:58:25 PM CEST
UPDATE AD_Column SET FieldLength=124, IsToolbarButton='N',Updated=TO_TIMESTAMP('2024-04-03 15:58:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59700
;
-- Apr 3, 2024, 3:58:27 PM CEST
ALTER TABLE AD_ChartDatasource MODIFY ValueColumn VARCHAR2(124 CHAR)
;

View File

@ -0,0 +1,239 @@
-- IDEMPIERE-6064 Error when creating a table with a long name through CreateTable process
SELECT register_migration_script('202404031226_IDEMPIERE-6064.sql') FROM dual;
-- Apr 3, 2024, 12:26:12 PM CEST
UPDATE AD_Column SET FieldLength=60, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:26:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=107
;
-- Apr 3, 2024, 12:26:13 PM CEST
INSERT INTO t_alter_column values('ad_table','TableName','VARCHAR(60)',null,null)
;
-- Apr 3, 2024, 12:26:43 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:26:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=116
;
-- Apr 3, 2024, 12:27:50 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=20,Updated=TO_TIMESTAMP('2024-04-03 12:27:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210871
;
-- Apr 3, 2024, 12:27:55 PM CEST
INSERT INTO t_alter_column values('ad_column','FKConstraintName','VARCHAR(63)',null,'NULL')
;
-- Apr 3, 2024, 12:28:10 PM CEST
INSERT INTO t_alter_column values('ad_column','ColumnName','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 12:28:52 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:28:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2602
;
-- Apr 3, 2024, 12:29:03 PM CEST
INSERT INTO t_alter_column values('ad_element','ColumnName','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 12:30:26 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:30:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210585
;
-- Apr 3, 2024, 12:30:27 PM CEST
INSERT INTO t_alter_column values('ad_viewcolumn','ColumnName','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 12:30:46 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 12:30:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=202042
;
-- Apr 3, 2024, 12:30:47 PM CEST
INSERT INTO t_alter_column values('ws_webservicefieldinput','ColumnName','VARCHAR(63)',null,'NULL')
;
-- Apr 3, 2024, 12:30:57 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:30:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208350
;
-- Apr 3, 2024, 12:30:58 PM CEST
INSERT INTO t_alter_column values('ad_infocolumn','ColumnName','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 12:31:30 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:31:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4017
;
-- Apr 3, 2024, 12:31:31 PM CEST
INSERT INTO t_alter_column values('ad_process_para','ColumnName','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 12:32:06 PM CEST
UPDATE AD_Column SET FieldLength=60,Updated=TO_TIMESTAMP('2024-04-03 12:32:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213696
;
-- Apr 3, 2024, 12:32:08 PM CEST
INSERT INTO t_alter_column values('ad_housekeeping','TableName','VARCHAR(60)',null,'NULL')
;
-- Apr 3, 2024, 12:33:04 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:33:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=216297
;
-- Apr 3, 2024, 12:33:12 PM CEST
INSERT INTO t_alter_column values('ad_tablepartition','Name','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 12:33:30 PM CEST
UPDATE AD_Column SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 12:33:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210522
;
-- Apr 3, 2024, 12:33:31 PM CEST
INSERT INTO t_alter_column values('ad_tableindex','Name','VARCHAR(63)',null,null)
;
-- Apr 3, 2024, 3:46:48 PM CEST
UPDATE AD_Process_Para SET FieldLength=60,Updated=TO_TIMESTAMP('2024-04-03 15:46:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53495
;
-- Apr 3, 2024, 3:46:58 PM CEST
UPDATE AD_Process_Para SET FieldLength=60,Updated=TO_TIMESTAMP('2024-04-03 15:46:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200354
;
-- Apr 3, 2024, 3:48:19 PM CEST
UPDATE AD_Column SET FieldLength=63, SeqNoSelection=10,Updated=TO_TIMESTAMP('2024-04-03 15:48:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11819
;
-- Apr 3, 2024, 3:48:27 PM CEST
INSERT INTO t_alter_column values('a_registrationattribute','ColumnName','VARCHAR(63)',null,'NULL')
;
-- Apr 3, 2024, 3:50:29 PM CEST
UPDATE AD_Process_Para SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 15:50:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200303
;
-- Apr 3, 2024, 3:51:50 PM CEST
UPDATE AD_Process_Para SET FieldLength=63,Updated=TO_TIMESTAMP('2024-04-03 15:51:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200306
;
-- Apr 3, 2024, 3:53:27 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:53:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5941
;
-- Apr 3, 2024, 3:53:36 PM CEST
INSERT INTO t_alter_column values('pa_measurecalc','BPartnerColumn','VARCHAR(124)',null,'x.C_BPartner_ID')
;
-- Apr 3, 2024, 3:54:01 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:54:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200528
;
-- Apr 3, 2024, 3:54:04 PM CEST
INSERT INTO t_alter_column values('gl_journalgeneratorline','BPColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:54:20 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:54:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59701
;
-- Apr 3, 2024, 3:54:23 PM CEST
INSERT INTO t_alter_column values('ad_chartdatasource','CategoryColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:55:11 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:55:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=54272
;
-- Apr 3, 2024, 3:55:14 PM CEST
INSERT INTO t_alter_column values('ad_sequence','DateColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:55:24 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:55:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5939
;
-- Apr 3, 2024, 3:55:26 PM CEST
INSERT INTO t_alter_column values('pa_measurecalc','DateColumn','VARCHAR(124)',null,'x.Date')
;
-- Apr 3, 2024, 3:55:26 PM CEST
UPDATE PA_MeasureCalc SET DateColumn='x.Date' WHERE DateColumn IS NULL
;
-- Apr 3, 2024, 3:55:42 PM CEST
UPDATE AD_Column SET FieldLength=124, IsToolbarButton='N',Updated=TO_TIMESTAMP('2024-04-03 15:55:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59673
;
-- Apr 3, 2024, 3:55:44 PM CEST
INSERT INTO t_alter_column values('ad_chartdatasource','DateColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:56:13 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:56:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5662
;
-- Apr 3, 2024, 3:56:14 PM CEST
INSERT INTO t_alter_column values('ad_reportview_col','FunctionColumn','VARCHAR(124)',null,null)
;
-- Apr 3, 2024, 3:56:37 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:56:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14780
;
-- Apr 3, 2024, 3:56:39 PM CEST
INSERT INTO t_alter_column values('pa_measurecalc','KeyColumn','VARCHAR(124)',null,null)
;
-- Apr 3, 2024, 3:56:52 PM CEST
UPDATE AD_Column SET FieldLength=124, IsToolbarButton='N',Updated=TO_TIMESTAMP('2024-04-03 15:56:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59677
;
-- Apr 3, 2024, 3:56:54 PM CEST
INSERT INTO t_alter_column values('ad_chartdatasource','KeyColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:57:25 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:57:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200214
;
-- Apr 3, 2024, 3:57:26 PM CEST
INSERT INTO t_alter_column values('ad_sequence','OrgColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:57:35 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:57:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5940
;
-- Apr 3, 2024, 3:57:36 PM CEST
INSERT INTO t_alter_column values('pa_measurecalc','OrgColumn','VARCHAR(124)',null,'x.AD_Org_ID')
;
-- Apr 3, 2024, 3:57:36 PM CEST
UPDATE PA_MeasureCalc SET OrgColumn='x.AD_Org_ID' WHERE OrgColumn IS NULL
;
-- Apr 3, 2024, 3:57:36 PM CEST
INSERT INTO t_alter_column values('pa_measurecalc','OrgColumn',null,'NOT NULL',null)
;
-- Apr 3, 2024, 3:57:49 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:57:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5942
;
-- Apr 3, 2024, 3:57:51 PM CEST
INSERT INTO t_alter_column values('pa_measurecalc','ProductColumn','VARCHAR(124)',null,'x.M_Product_ID')
;
-- Apr 3, 2024, 3:58:03 PM CEST
UPDATE AD_Column SET FieldLength=124,Updated=TO_TIMESTAMP('2024-04-03 15:58:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210647
;
-- Apr 3, 2024, 3:58:04 PM CEST
INSERT INTO t_alter_column values('ad_chartdatasource','SeriesColumn','VARCHAR(124)',null,'NULL')
;
-- Apr 3, 2024, 3:58:25 PM CEST
UPDATE AD_Column SET FieldLength=124, IsToolbarButton='N',Updated=TO_TIMESTAMP('2024-04-03 15:58:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=59700
;
-- Apr 3, 2024, 3:58:27 PM CEST
INSERT INTO t_alter_column values('ad_chartdatasource','ValueColumn','VARCHAR(124)',null,null)
;

View File

@ -233,14 +233,14 @@ public class CreateTable extends SvrProcess {
} }
String uucolName = PO.getUUIDColumnName(p_tableName); String uucolName = PO.getUUIDColumnName(p_tableName);
M_Element elementUU = M_Element.get(getCtx(), p_tableName + "_UU"); M_Element elementUU = M_Element.get(getCtx(), uucolName);
if (elementUU == null) { // Create Element <TableName> + _UU if (elementUU == null) { // Create Element <TableName> + _UU
elementUU = new M_Element(getCtx(), uucolName, p_entityType, get_TrxName()); elementUU = new M_Element(getCtx(), uucolName, p_entityType, get_TrxName());
elementUU.saveEx(); elementUU.saveEx();
} }
if (createColumn(table, elementUU.getColumnName()) > 0) { if (createColumn(table, elementUU.getColumnName()) > 0) {
// UUID Index and Constraint // UUID Index and Constraint
MTableIndex tiuu = new MTableIndex(table, table.getTableName() + "_uu_idx"); MTableIndex tiuu = new MTableIndex(table, MTable.getUUIDIndexName(table.getTableName()));
tiuu.setIsCreateConstraint(true); tiuu.setIsCreateConstraint(true);
tiuu.setIsUnique(true); tiuu.setIsUnique(true);
tiuu.setIsKey(table.isUUIDKeyTable()); tiuu.setIsKey(table.isUUIDKeyTable());
@ -323,12 +323,24 @@ public class CreateTable extends SvrProcess {
else else
colElementID = createColumn(tableTrl, elementUU.getColumnName()); // <TableName>_UU (UUID of parent table) colElementID = createColumn(tableTrl, elementUU.getColumnName()); // <TableName>_UU (UUID of parent table)
M_Element elementTrlUU = M_Element.get(getCtx(), tableTrl.getTableName() + "_UU"); String uuTrlcolName = PO.getUUIDColumnName(tableTrl.getTableName());
M_Element elementTrlUU = M_Element.get(getCtx(), uuTrlcolName);
if (elementTrlUU == null) { if (elementTrlUU == null) {
elementTrlUU = new M_Element(getCtx(), tableTrl.getTableName() + "_UU", p_entityType, get_TrxName()); elementTrlUU = new M_Element(getCtx(), uuTrlcolName, p_entityType, get_TrxName());
elementTrlUU.saveEx(); elementTrlUU.saveEx();
} }
createColumn(tableTrl, elementTrlUU.getColumnName()); // <TableName>_Trl_UU if (createColumn(tableTrl, elementTrlUU.getColumnName()) > 0) {
// UUID Index and Constraint
MTableIndex tiuutrl = new MTableIndex(tableTrl, MTable.getUUIDIndexName(tableTrl.getTableName()));
tiuutrl.setIsCreateConstraint(true);
tiuutrl.setIsUnique(true);
tiuutrl.setIsKey(tableTrl.isUUIDKeyTable());
tiuutrl.saveEx();
MColumn uuTrlColumn = getColumn(tableTrl, uuTrlcolName);
MIndexColumn icuuTrl = new MIndexColumn(tiuutrl, uuTrlColumn, 10);
icuuTrl.saveEx();
}
int colLanguageID = createColumn(tableTrl, "AD_Language"); int colLanguageID = createColumn(tableTrl, "AD_Language");
createColumn(tableTrl, "IsTranslated"); createColumn(tableTrl, "IsTranslated");
@ -430,6 +442,7 @@ public class CreateTable extends SvrProcess {
* Create a column if it doesn't exist * Create a column if it doesn't exist
* @param table * @param table
* @param columnName * @param columnName
* @return AD_Column_ID just column is created, if the column already exists return -1
*/ */
private int createColumn(MTable table, String columnName) { private int createColumn(MTable table, String columnName) {
MColumn columnThatExists = getColumn(table, columnName); MColumn columnThatExists = getColumn(table, columnName);

View File

@ -43,6 +43,9 @@ public interface AdempiereDatabase
/** default lock timeout, 60 seconds **/ /** default lock timeout, 60 seconds **/
static final int LOCK_TIME_OUT = 60; static final int LOCK_TIME_OUT = 60;
/* PostgreSQL restricts object names to 63 characters */
public final static int MAX_OBJECT_NAME_LENGTH = 63;
/** /**
* Get Database Name * Get Database Name
* @return database short name * @return database short name

View File

@ -58,7 +58,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
/** /**
* generated serial id * generated serial id
*/ */
private static final long serialVersionUID = -971225879649586290L; private static final long serialVersionUID = -528009647661217241L;
/** /**
* Get MColumn from Cache (immutable) * Get MColumn from Cache (immutable)
@ -717,9 +717,8 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
{ {
if (isKey()) { if (isKey()) {
StringBuilder constraintName; StringBuilder constraintName;
if (tableName.length() > 26) if (tableName.length() > AdempiereDatabase.MAX_OBJECT_NAME_LENGTH - 4)
// Oracle restricts object names to 30 characters constraintName = new StringBuilder(tableName.substring(0, AdempiereDatabase.MAX_OBJECT_NAME_LENGTH - 4)).append("_Key");
constraintName = new StringBuilder(tableName.substring(0, 26)).append("_Key");
else else
constraintName = new StringBuilder(tableName).append("_Key"); constraintName = new StringBuilder(tableName).append("_Key");
StringBuilder msgreturn = new StringBuilder("CONSTRAINT ").append(constraintName).append(" PRIMARY KEY (").append(getColumnName()).append(")"); StringBuilder msgreturn = new StringBuilder("CONSTRAINT ").append(constraintName).append(" PRIMARY KEY (").append(getColumnName()).append(")");
@ -735,11 +734,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
MTable table = MTable.get(getAD_Table_ID()); MTable table = MTable.get(getAD_Table_ID());
// IDEMPIERE-965 // IDEMPIERE-965
if (getColumnName().equals(PO.getUUIDColumnName(tableName))) { if (getColumnName().equals(PO.getUUIDColumnName(tableName))) {
StringBuilder indexName = new StringBuilder().append(getColumnName()).append("_idx"); String indexName = MTable.getUUIDIndexName(tableName);
if (indexName.length() > 30) {
indexName = new StringBuilder().append(getColumnName().substring(0, 25));
indexName.append("uuidx");
}
String constraintType; String constraintType;
if (table.isUUIDKeyTable()) if (table.isUUIDKeyTable())
constraintType = "PRIMARY KEY"; constraintType = "PRIMARY KEY";
@ -1293,8 +1288,8 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
constraintName.append(columnName.replace("_", "")); constraintName.append(columnName.replace("_", ""));
constraintName.append("_"); constraintName.append("_");
constraintName.append(table.getTableName().replace("_", "")); constraintName.append(table.getTableName().replace("_", ""));
if (constraintName.length() > 30) if (constraintName.length() > AdempiereDatabase.MAX_OBJECT_NAME_LENGTH)
constraintName = new StringBuilder(constraintName.substring(0, 30)); constraintName = new StringBuilder(constraintName.substring(0, AdempiereDatabase.MAX_OBJECT_NAME_LENGTH));
fkConstraintName = constraintName.toString(); fkConstraintName = constraintName.toString();
int duplicateId = DB.getSQLValueEx(column.get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE Upper(FkConstraintName)=?", fkConstraintName.toUpperCase()); int duplicateId = DB.getSQLValueEx(column.get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE Upper(FkConstraintName)=?", fkConstraintName.toUpperCase());
@ -1303,8 +1298,8 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
{ {
loop++; loop++;
String suffix = "" + loop; String suffix = "" + loop;
if (fkConstraintName.length() + suffix.length() > 30) if (fkConstraintName.length() + suffix.length() > AdempiereDatabase.MAX_OBJECT_NAME_LENGTH)
fkConstraintName = fkConstraintName.substring(0, fkConstraintName.length() - (fkConstraintName.length() + suffix.length() - 30)); fkConstraintName = fkConstraintName.substring(0, fkConstraintName.length() - (fkConstraintName.length() + suffix.length() - AdempiereDatabase.MAX_OBJECT_NAME_LENGTH));
fkConstraintName = fkConstraintName + loop; fkConstraintName = fkConstraintName + loop;
duplicateId = DB.getSQLValueEx(column.get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE Upper(FkConstraintName)=?", fkConstraintName.toUpperCase()); duplicateId = DB.getSQLValueEx(column.get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE Upper(FkConstraintName)=?", fkConstraintName.toUpperCase());
} }

View File

@ -65,9 +65,9 @@ import org.idempiere.cache.ImmutablePOSupport;
public class MTable extends X_AD_Table implements ImmutablePOSupport public class MTable extends X_AD_Table implements ImmutablePOSupport
{ {
/** /**
* generated serial id *
*/ */
private static final long serialVersionUID = 4325276636597337437L; private static final long serialVersionUID = -167824144142429242L;
public final static int MAX_OFFICIAL_ID = 999999; public final static int MAX_OFFICIAL_ID = 999999;
@ -1084,4 +1084,18 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport
tablePartitionNames.add(partition.getName()); tablePartitionNames.add(partition.getName());
return tablePartitionNames; return tablePartitionNames;
} }
/**
* Get the Unique UU Index name
* @return indexName
*/
public static String getUUIDIndexName(String tableName) {
StringBuilder indexName = new StringBuilder().append(PO.getUUIDColumnName(tableName)).append("_idx");
if (indexName.length() > AdempiereDatabase.MAX_OBJECT_NAME_LENGTH)
indexName = new StringBuilder().append(PO.getUUIDColumnName(tableName).substring(0, AdempiereDatabase.MAX_OBJECT_NAME_LENGTH - 5)).append("uuidx");
return indexName.toString();
}
} // MTable } // MTable

View File

@ -57,6 +57,7 @@ import org.adempiere.exceptions.DBException;
import org.adempiere.process.UUIDGenerator; import org.adempiere.process.UUIDGenerator;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.acct.Doc; import org.compiere.acct.Doc;
import org.compiere.db.AdempiereDatabase;
import org.compiere.util.AdempiereUserError; import org.compiere.util.AdempiereUserError;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogMgt; import org.compiere.util.CLogMgt;
@ -5567,9 +5568,21 @@ public abstract class PO
* @return uuid column name * @return uuid column name
*/ */
public static String getUUIDColumnName(String tableName) { public static String getUUIDColumnName(String tableName) {
// easy case, just add suffix when the table name is shorter or equal than 27 chars
String columnName = tableName + "_UU"; String columnName = tableName + "_UU";
if (columnName.length() > 30) { if (columnName.length() <= 30) /* Old MAX_OBJECT_NAME_LENGTH */
return columnName;
// verify if oldColumnName exists
int i = columnName.length() - 30; int i = columnName.length() - 30;
String oldColumnName = tableName.substring(0, tableName.length() - i) + "_UU";
MTable table = MTable.get(null, tableName);
if (table != null && table.columnExists(oldColumnName))
return oldColumnName;
if (columnName.length() > AdempiereDatabase.MAX_OBJECT_NAME_LENGTH) {
i = columnName.length() - AdempiereDatabase.MAX_OBJECT_NAME_LENGTH;
columnName = tableName.substring(0, tableName.length() - i) + "_UU"; columnName = tableName.substring(0, tableName.length() - i) + "_UU";
} }
return columnName; return columnName;

View File

@ -37,6 +37,7 @@ import org.compiere.model.MBPartner;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MOrder; import org.compiere.model.MOrder;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.model.X_Test; import org.compiere.model.X_Test;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -465,4 +466,20 @@ public class DBTest extends AbstractTestCase
} }
} }
/**
* Test max length of UUID column name and its index
*/
@Test
public void testUUIDColumnName() {
assertEquals(PO.getUUIDColumnName ("MyTable" ), "MyTable_UU" );
assertEquals(PO.getUUIDColumnName ("XCUSTOM_ThisIsAVeryLongTableNameWithSixtyCharactersOnTheName" ), "XCUSTOM_ThisIsAVeryLongTableNameWithSixtyCharactersOnTheName_UU");
assertEquals(PO.getUUIDColumnName ("CUSTOM_AVeryLongTableNameWithMoreThanSixtyCharactersOnTheName"), "CUSTOM_AVeryLongTableNameWithMoreThanSixtyCharactersOnTheNam_UU");
assertEquals(MTable.getUUIDIndexName("MyTable" ), "MyTable_UU_idx" );
assertEquals(MTable.getUUIDIndexName("XCUSTOM_ThisIsAVeryLongTableNameWithSixtyCharactersOnTheName" ), "XCUSTOM_ThisIsAVeryLongTableNameWithSixtyCharactersOnTheNauuidx");
assertEquals(MTable.getUUIDIndexName("CUSTOM_AVeryLongTableNameWithMoreThanSixtyCharactersOnTheName"), "CUSTOM_AVeryLongTableNameWithMoreThanSixtyCharactersOnTheNuuidx");
assertEquals(MTable.getUUIDIndexName("XYCUSTOM_ThisIsAVeryLongTableNameWith55CharactersOnName" ), "XYCUSTOM_ThisIsAVeryLongTableNameWith55CharactersOnName_UU_idx" );
assertEquals(MTable.getUUIDIndexName("XYZCUSTOM_ThisIsAVeryLongTableNameWith56CharactersOnName" ), "XYZCUSTOM_ThisIsAVeryLongTableNameWith56CharactersOnName_UU_idx");
assertEquals(MTable.getUUIDIndexName("XYZACUSTOM_ThisIsAVeryLongTableNameWith57CharactersOnName" ), "XYZACUSTOM_ThisIsAVeryLongTableNameWith57CharactersOnName_uuidx");
}
} }