Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: [OT] MySQL recalibrating a sort-index

by LanX (Saint)
on Feb 16, 2018 at 22:43 UTC ( [id://1209342]=note: print w/replies, xml ) Need Help??


in reply to Re^3: [OT] MySQL recalibrating a sort-index
in thread [OT] MySQL recalibrating a sort-index

I haven't tested it yet, but why does an UPDATE from a temp table have no conflict with the UNIQUEness of f_sort (see the UPDATE in the OP)?

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

  • Comment on Re^4: [OT] MySQL recalibrating a sort-index

Replies are listed 'Best First'.
Re^5: [OT] MySQL recalibrating a sort-index
by erix (Prior) on Feb 17, 2018 at 08:13 UTC

    Ah, you were looking for a DEFERRABLE CONSTRAINT, which postpones the constraint-validation to the end of a transaction.

    So, you'd do (again, postgres):

    create table tree ( f_node_id int primary key , f_parent_id int , f_name text , f_sort float , constraint tree_parent_sort_uniq_idx unique (f_parent_id, f_sort) d +eferrable );

    This lets you mess about with non-unique states for the duration of a transaction. The constraint (here: uniqueness) is only then enforced.

    I can't imagine MariaDB does not have this functionality but I can't find it in the documentation. (I looked for DEFERRED or DEFERRABLE. The MariaDB docs list 'DEFERRED' as a reserved word but I see no functionality associated with it.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1209342]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found