-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Partial Indexes #1048
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
Partial Indexes #1048
Conversation
vrana
left a comment
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.
Please also add an entry to changelog.
adminer/include/adminer.inc.php
Outdated
|
|
||
| $partial_index_condition_exists = false; | ||
| foreach ($indexes as $name => $index) { | ||
| $partial_index_condition_exists |= $index["partial_index_condition"]; |
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.
Fatal error: Uncaught TypeError: Unsupported operand types: int | string in adminer\include\adminer.inc.php:356
adminer/drivers/pgsql.inc.php
Outdated
| $columns = get_key_vals("SELECT attnum, attname FROM pg_attribute WHERE attrelid = $table_oid AND attnum > 0", $connection2); | ||
| foreach ( | ||
| get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption, (indpred IS NOT NULL)::int as indispartial, pg_am.amname as algorithm | ||
| get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption, (indpred IS NOT NULL)::int as indispartial, pg_am.amname as algorithm, pg_get_expr(pg_index.indpred, pg_index.indrelid, true) AS partial_index_condition |
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 would name this just partial.
adminer/drivers/pgsql.inc.php
Outdated
| $columns = get_key_vals("SELECT attnum, attname FROM pg_attribute WHERE attrelid = $table_oid AND attnum > 0", $connection2); | ||
| foreach ( | ||
| get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption, (indpred IS NOT NULL)::int as indispartial, pg_am.amname as algorithm | ||
| get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption, (indpred IS NOT NULL)::int as indispartial, pg_am.amname as algorithm, pg_get_expr(pg_index.indpred, pg_index.indrelid, true) AS partial_index_condition |
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.
Please check if pg_get_expr is available in CockroachDB and call it conditionally if not.
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.
It should be supported: cockroachdb/cockroach#10952
adminer/drivers/pgsql.inc.php
Outdated
| $queries[] = "CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . ($val[3] ? " USING $val[3]" : "") . " (" . implode(", ", $val[2]) . ")"; | ||
| $index_condition = ""; | ||
| if ($val[4]) { | ||
| $index_condition = " WHERE ".$val[4]; |
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.
Inline the string: "WHERE $val[4]"
adminer/drivers/pgsql.inc.php
Outdated
| if ($val[4]) { | ||
| $index_condition = " WHERE ".$val[4]; | ||
| } | ||
| $queries[] = "CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . ($val[3] ? " USING $val[3]" : "") . " (" . implode(", ", $val[2]) . ")".$index_condition; |
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.
Wrap this to more lines using logical blocks. Then you can inline $index_condition here.
adminer/include/adminer.inc.php
Outdated
| echo "<th>$index[type]" . ($index['algorithm'] != first(driver()->indexMethods()) ? " ($index[algorithm])" : ""); | ||
| echo "<td>" . implode(", ", $print); | ||
| if ($partial_index_condition_exists) { | ||
| echo "<td>" . ($index['partial_index_condition'] ? "WHERE ".$index['partial_index_condition'] : ""); |
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.
This needs to call h().
adminer/include/adminer.inc.php
Outdated
| echo "<th>$index[type]" . ($index['algorithm'] != first(driver()->indexMethods()) ? " ($index[algorithm])" : ""); | ||
| echo "<td>" . implode(", ", $print); | ||
| if ($partial_index_condition_exists) { | ||
| echo "<td>" . ($index['partial_index_condition'] ? "WHERE ".$index['partial_index_condition'] : ""); |
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.
Space around ..
| echo "<td>" . implode(", ", $print); | ||
| if ($partial_index_condition_exists) { | ||
| echo "<td>" . ($index['partial_index_condition'] ? "WHERE ".$index['partial_index_condition'] : ""); | ||
| } |
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.
This could look nicer if wrapped into "<code class='jush-" . JUSH . "'>".
adminer/lang/xx.inc.php
Outdated
| '<a%s>Configure</a> %s in %s.' => '<a%s>Xx</a> %s xx %s.', | ||
| 'screenshot' => 'xx', | ||
| 'Algorithm' => 'Xx', | ||
| 'Condition' => 'Xx', |
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.
Move to the block with Index translations.
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 think that both Algorithm / Condition are quite common terms but fixed
|
Also consider adding tests for new features so that they don't break in the future. You need Katalon Recorder to run the tests. |
adminer/drivers/pgsql.inc.php
Outdated
| } else { | ||
| $queries[] = "CREATE INDEX " . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) . ($val[3] ? " USING $val[3]" : "") . " (" . implode(", ", $val[2]) . ")"; | ||
| $index_condition = ""; | ||
| if ($val[4]) { |
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.
Update doc-comment in mysql.inc.php.
No description provided.