Skip to content

Conversation

@salacr
Copy link
Contributor

@salacr salacr commented Apr 16, 2025

No description provided.

Copy link
Owner

@vrana vrana left a 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.


$partial_index_condition_exists = false;
foreach ($indexes as $name => $index) {
$partial_index_condition_exists |= $index["partial_index_condition"];
Copy link
Owner

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

$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
Copy link
Owner

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.

$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
Copy link
Owner

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.

Copy link
Contributor Author

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

$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];
Copy link
Owner

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]"

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;
Copy link
Owner

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.

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'] : "");
Copy link
Owner

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().

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'] : "");
Copy link
Owner

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'] : "");
}
Copy link
Owner

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 . "'>".

'<a%s>Configure</a> %s in %s.' => '<a%s>Xx</a> %s xx %s.',
'screenshot' => 'xx',
'Algorithm' => 'Xx',
'Condition' => 'Xx',
Copy link
Owner

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.

Copy link
Contributor Author

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

@vrana
Copy link
Owner

vrana commented Apr 17, 2025

Also consider adding tests for new features so that they don't break in the future. You need Katalon Recorder to run the tests.

} 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]) {
Copy link
Owner

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.

@vrana vrana merged commit c6d7373 into vrana:master Apr 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants