-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Inttest adding tests using big fileids #28364
Conversation
After using this app and doing curl -X POST http://admin:[email protected]/html/multilinkshares/ocs/v1.php/apps/testing/api/v1/increasefileid Checking oc_filecache table in the database I see the entry correctly added. But when accessing the server there is an exception:
|
OK, it is ready. It increases the fileid in the before suite statement only if it is not present already. @VicDeo This PR should wait for your fix. You could do it here or I'll rebase it after it is merged, as you wish. |
So...
If a column has an autoincrement this will produce the query and postgre will die: |
1f4b513
to
bf00edd
Compare
@VicDeo are you saying that postgres has no support for bigint ?? |
@PVince81 no, I say that design of doctrine/dbal leaves no room for a clean solution.
To prevent this I can skip this migration step for this field on postgre and write plain SQL migration with a direct UPD.
PostgreSqlPlatform::getAlterTableSQL will produce the following two queries:
To prevent 2. migration should have a new default that is constructed according to Postgres rules:
|
@DeepDiver1975 I'd like your input on this #28364 (comment) We could also try to submit a PR upstream to Doctrine/dbal... |
2787ecc
to
c0dd51a
Compare
See #28429 |
hmm. there is no crash locally |
22a7268
to
ce6736a
Compare
@PVince81 @DeepDiver1975 All tests are green. |
@@ -13,7 +13,7 @@ | |||
<default>0</default> | |||
<notnull>true</notnull> | |||
<autoincrement>1</autoincrement> | |||
<length>4</length> | |||
<length>10</length> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I thought @phisch got rid of these files when he converted 8.2 stuff to migrations. But maybe these were older schemas that didn't need migrating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about - for the sake of clearness - to kill all database.xml files and add them as migrations ....
// BIGSERIAL could not be used in statements altering column type | ||
// That's why we replace it with BIGINT | ||
// see https://github.com/owncloud/core/pull/28364#issuecomment-315006853 | ||
if (preg_match('|(ALTER TABLE\s+\S+\s+ALTER\s+\S+\s+TYPE\s+)(BIGSERIAL)|i', $sql, $matches)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you try doing this earlier, maybe within the schema diff ? or is the word "BIGSERIAL" generated very late ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PVince81 sqls are generated in line 68 $sqls = $schemaDiff->toSql($connection->getDatabasePlatform());
// see https://github.com/owncloud/core/pull/28364#issuecomment-315006853 | ||
if (preg_match('|(ALTER TABLE\s+\S+\s+ALTER\s+\S+\s+TYPE\s+)(BIGSERIAL)|i', $sql, $matches)){ | ||
$alterTable = $matches[1]; | ||
$sql = $alterTable . 'BIGINT'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange, you just append it to the end ? wouldn't BIGSERIAL appear in the middle of a statement sometimes ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PVince81 Pure regexp magic. I capture everything into $matches
(something)(anotherthing)
when the input string is somethinganotherthing
$matches[0]
will be somethinganotherthing
$matches[1]
will be something
$matches[2]
will be anotherthing
in this case
$matches[1]
is ALTER TABLE whatever ALTER somecolumn TYPE
and
$matches[2]
is BIGSERIAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if there is more than one column in a single ALTER statement, or does Doctrine always split these ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PVince81 schemaDiff generates statements per column https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L521
|
||
// Fixup postgres autoincrement | ||
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform){ | ||
$default = sprintf("nextval('%s_%s_seq'::regclass)", $table->getName(), $idColumn->getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sad if we can't do this inside of PostgreSqlPlatform
. Will we need this statement in more places ? Worst case, put it as a utility function in PostgreSqlPlatform
then for reusability ?
Ok, I just saw your comment that you already looked into some way to do it in Doctrine. Since it's not possible, let's see if we can make parts of this code reusable, especially the logic for |
ce6736a
to
d854ce6
Compare
lib/private/DB/ConnectionFactory.php
Outdated
@@ -129,6 +129,10 @@ public function getConnection($type, $additionalConnectionParams) { | |||
$additionalConnectionParams['platform'] = new OCSqlitePlatform(); | |||
$eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode)); | |||
break; | |||
case 'pgsql': | |||
case 'postgresql': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postgresql? we do support this key?
use Doctrine\DBAL\Schema\TableDiff; | ||
use Doctrine\DBAL\Types\Type; | ||
|
||
class OCPostgreSqlPlatform extends \Doctrine\DBAL\Platforms\PostgreSqlPlatform { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ...
|
||
class OCPostgreSqlPlatform extends \Doctrine\DBAL\Platforms\PostgreSqlPlatform { | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent looks off
Rebased - this was really out dated - please always update your branches - thx |
if stuff above is addressed: 👍 |
Talked with @DeepDiver1975: let's not backport the bigint fileid thing. People should upgrade, especially considering that we're preparing a way already to upgrade from 8.2 to 10 (upgrade from 9.0 to 10 is already possible): |
@DeepDiver1975 updated |
@VicDeo sorry for the confusion. This is to be released for 10.0.3, so backport to stable10. But nothing for OC <= 9.1 |
…emental number Added entry point to testing api Added behaviour to use fileids beyond 32 bits in tests Port is variable, we need to take that into account
913441a
to
20fa3f0
Compare
Rebased for CI |
@PVince81 @DeepDiver1975 Tests are passed. Can't merge without approval |
@VicDeo please backport to stable10 |
Stable10: #28581 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Altering most of relevant to file_id columns to be BIGINT.
Ref #26901
With integration tests.
Not sure if I am in the right path, @PVince81 what do you think?