UPDATE with variables to renumber column gives syntax error

Searching for a way to renumber a column within mysql, I’ve found multiple articles showing the same approach:

  • Renumbering an Ordering Field in MySQL
  • How to update a MySql column with ascending numbers

among others.

But trying it on my table I get a syntax error.

mysql> SET @rankStart = 10; mysql> SET @rankInc = 10; mysql> UPDATE fileFileTbl SET rank = (@rankStart := @rankStart + @rankInc) ORDER BY `rank` ASC; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank = (@rankStart := @rankStart + @rankInc) ORDER BY `rank` ASC' at line 1 

The command looks identical to the articles posted. What am I missing?

Here’s the table (with some columns omitted):

CREATE TABLE `fileFileTbl` (   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,   `fileEngineId` int(11) DEFAULT NULL,   `rank` int(11) DEFAULT '0',   `fileName` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'newfile',   PRIMARY KEY (`id`),   UNIQUE KEY `fileEngineId` (`fileEngineId`,`rank`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; 

System is Centos 8, with mysql as:

# mysql --version mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution) 

SAT satisfaction with 10 variables

I am trying to prove that the next problem is NPC:

$ A=$ {$ <\phi>|\phi \,\,\,is\,\,\,a\,\,\,CNF\,\,\,and\,\,\,has\,\,\,satisfying\,\,\,assignment\,\,\,where\,\,\,exactly\,\,\,10\,\,\,variables\,\,\,are\,\,\,TRUE$ }

I am trying to find polynomial mapping reduction from SAT but I can’t find a way to force exactly 10 variables to get TRUE assignment. My idea was to create new formula, with 10 clauses, each clause is the intersection of a new variable $ x_i$ with the old formula, but I don’t see how my idea helpful.

I would appreciate help.

How to use ‘Bind Variables’ in a ‘Dynamic Query ‘ when the exact number of variables are not known

I have a procedure in which I’m using Dynamic SQL. The input parameteri_tables is a string which is a concatenation of the name of some tables . It might be one these :

1)All tables test_table1,test_table2,test_table3.

2)Only two tables , for instance test_table2,test_table3 .

3)Nothing .So NULL will pass to the procedure.

I’ve read about Bind variable and the significant role it has in preventing injection and improving performance. I want to use bind variable in my procedure but there is one things I don’t know how to handle :

As you can see we do not know the exact number of variables.It might be one , two , three or nothing. Depending on The input parameteri_tables.

   create or replace procedure bind_variable_test(i_tables varchar2,                                                   i_cid    number,                                                   o_result out sys_refcursor) is     actual_query varchar2(1000) := '';    begin         -- this is the base query     actual_query := 'select *                 from z_test_a t1                   inner join z_test_b t2                 on t1.id = t2.id';      -- check input parameter " i_tables "       if i_tables like '%test_table1%' then              actual_query := actual_query || '  inner join test_table1 t3 on t3.id = t1.id and                              t3.cid = ' || i_cid;      end if;       if i_tables like '%test_table2%' then             actual_query := actual_query || '  inner join test_table2 t4 on t4.id = t1.id and                              t4.cid = ' || i_cid;      end if;       if i_tables like '%test_table3%' then             actual_query := actual_query || '  inner join test_table3 t5 on t5.id = t1.id and                    t5.cid = ' || i_cid;      end if;      open o_result for actual_query;     end; 

How do you convert an NP problem which runs in O(f(x)) time in a SAT instance with O(f(x)*log(f(x))) variables in O(f(x)*log(f(x)))

I looked at the Cook’s theorem at Wikipedia which presents a way to convert any NP problem to SAT but it seems to require O(f(x)^3) variables. Is it possible to remove some of the checks in the conversion so to make it O(f(x)*log(f(x))) in variables and time?

Getting and setting CSS variables with JQuery in WordPress backend fails

On a WordPress settings page of a plugin I develop, I have to implement a visual element that I want to change by JavaScript. I’ve got my solution working as it should and tested it on code-pen and JSFiddle. But when loading the equivilant code including the script, it will not work.

Here is the schema I’m using: HTML

<div id="origin" class="box"></div> <div id="target" class="box"></div> <button id="toggle-color">Toggle Color</button> 

CSS

:root {   --origin-color: red;   --target-color: blue; }  .box{   width: 150px;   height: 150px; }  #origin{   background-color: var(--origin-color); }  #target{   background-color: var(--target-color); } 

JS (jQuery 3.4.1)

(function( $   ) {     'use strict';     $  (document).ready(function(){               $  ('#toggle-color').on('click', function(event){         event.preventDefault();         var root = $  (":root");         var origin_color = '--origin-color';         var target_color = '--target-color';         var origin_value = root.css(origin_color);         var target_value = root.css(target_color);         root.css(origin_color, target_value);           root.css(target_color, origin_value);         return false;       });   });     })( jQuery ); 

The Problem I have is, that while it is working in test environments in the WordPress backend, the lines where I fetch the colors with

var origin_value = root.css(origin_color); var target_value = root.css(target_color); 

returns ‘undefined’, so the next line where I switch the colors fails.

See my example here: https://jsfiddle.net/tomybyte/hvbc3zu1/6/

I don’t understand why it is working in JSFiddle and code-pen but not when loading in WordPress (yes the code is loaded, I checked that!)

In the dataflow programming paradigm programs are modeled as directed graphs. Are the edges of the graph variables? And are the vertexes functions?

As I understand it in dataflow programming, programs are structured as directed graphs, an example of which is below enter image description here

Is it true to say that the arrows (or edges) represent the variables within a program and the vertexes (blue circles) represent programmatic functions? Or is this too much of a simplification?

I am interested in understanding how dataflow languages actually apply graph theory.

Why is the Halting problem decidable for Goto languages limited on the highest value of constants and variables?

This is taken from an old exam of my university that I am using to prepare myself for the coming exam:

Given is a language $ \text{Goto}_{17}^c \subseteq \text{Goto}$ . This language contains exactly those $ \text{Goto}$ programs in which no constant is ever above $ 17$ nor any variable ever above $ c$ .

$ Goto$ here describes the set of all programs written in the $ Goto$ language made up of the following elements:

With variables $ v_i \in \mathbb{N}$ and constants $ c \in \mathbb{N}$
Assignment: $ x_i := c, x_i := x_i \pm c$
Conditional Jump: if(Comparison) goto $ L_i$
Haltcommand: halt

I am currently struggling with the formalization of a proof, but this is what I have come to so far, phrased very casually: For any given program in this set we know that it is finite. A finite program contains a finite amount of variables and a finite amount of states, or lines to be in. As such, there is a finite amount of configurations in which this process can be. If we let this program run, we can keep a list of all configurations we have seen. That is, the combination of all used variable-values and the state of the program. If we let the program run, there must be one of two things that happens eventually: The program halts. In this case, we return YES and have decided that it halts. The program reaches a configuration that has been recorded before. As the language is deterministic, this means that we must have gone a full loop which will exactly repeat now.

No other case can exist as that would mean that we keep running forever on finite code without repeating a configuration. This means after every step, among our list of infinite steps, there is a new configuration. This would mean that there are infinite configurations, which is a contradiction.

Is this correct? Furthermore, how would a more formal proof look if it is? If not, how would a correct proof look?

Effects of limitations of the variables and constants of Goto languages

I am currently looking at a set of problems which all deal with attributes of a certain subset of Goto programs which have certain limitations. They are as follows:

  1. $ \text{Goto}_{17}$ describes the set of all Goto-programs in which no constant is greater than $ 17$ . Show that every Goto-program can be emulated by a $ \text{Goto}_{17}$ -program.
  2. $ \text{Goto}_{17}^{c}$ describes the set of all Goto-programs in which variables can be no higher than c and constants no higher than 17. Why is the Halting-problem decideable for this set of programs?

Following are my thoughts so far on these problems:

  1. It is rather easy to see that any given program can be trivially converted into not using constants higher than 17 by repeating any operation that would do so as often as necessary to evoke the same result. Even comparisons can work by using a dummy variable to store the variables value, then comparing to 17, reducing the variable and so on, until we have compared it against what we want to compare it to. And there will always be a variable easily chosen for this if we just spread out the variables so that in our new $ \text{Goto}_{17}$ -program only every second variable is used for normal calculation. This way we can always work with any variables "dummy-partner" variable for calculations like this without loosing the value. This all feels very unpolished though and I struggle with formulating it in a way that makes it into an actual proof. Am I on the right track and how can this be explained better if yes? How at all, if no?
  2. In this case I am even less confident in my basic idea. We almost have a situation in which I am confident to say that we can just go through every state of the program that is even theoretically possible and decide whether it can hold in that state. But how do I know of a state whether it is also practically possible, or in other words, does the program actually ever reach this constellation of variable values and position in code? We can’t just simulate the program, as infinite loops are still possible here in contrast to more simple languages like loop-languages. Why can the Halting-Problem be solved in this case? What is the method to achieve this? Can we maybe guarantee that on a set of finite amounts of variables (which is given, as the code must be finite) we must at some point reach a situation where we either halt or where our state exactly matches a prior state, as all these variables have a finite amount of states they can be in?

Is Monotone 3-SAT with exactly 3 distinct variables untractable?

I have given the following SAT variation:

Given a formula F in CNF where each clause C has exactly 3 distinct literals and for each C in F either all literals are positive or all literals are negated. Example:

$ F= (x_1\vee x_2 \vee x_4) \wedge (\neg x_2\vee \neg x_3 \vee \neg x_4) \wedge (x_3\vee x_4 \vee x_5)$

Is this variation of SAT tractable?

My findings so far:

I suspect the problem is NP-complete and therefore not tractable. Thus I would like to perform a poly-reduction from 3-SAT to the variation described above.

An arbitrary 3-SAT formula can be converted to monotone 3-SAT.

Take following example:

$ C_1=(x_1\vee x_2 \vee \neg x_3)$ and define $ z_3$ by $ \neg x_3 \leftrightarrow z_3$ and $ x_3 \leftrightarrow \neg z_3$ which is equivalent to $ (x_3\vee z_3)\wedge(\neg x_3 \vee \neg z_3)$ .

From that we get the monotone form of $ C_1$ by

$ (x_1\vee x_2 \vee \neg x_3) \leftrightarrow (x_1\vee x_2 \vee z_3)\wedge (x_3\vee z_3)\wedge(\neg x_3 \vee \neg z_3)$

By applying this transformation to all clauses I get a monotone 3-SAT formula which is equally satisfiable.

My reduction produces additional 2 clauses with 2 literals for each non-monotone clause, but how do I get only monotone clauses with exactly 3 distinct literals?

Generate all combinations for variables and insert into temp table

0

I have one requirement there are 4 variables and i want all combinations of 4 variables and insert into temp table .

DECLARE StartDateTime DATETIME; DECLARE Age INT;  DECLARE Duration INT ; DECLARE TotalDD INT;  CREATE TEMPORARY TABLE tempTable(     Duration INT,     TotalDD INT,     Age INT,     StartDateTime DATETIME,     ); SET Age = 16; SET TotalDD = 14; SET Duration = 30; SET StartDateTime = CURDATE(); 

Excepted Result:

Duration age TotalDD StartDateTime 30 null null null null 16 null null 30 null null null 30 16 null null null null 14 20200622 30 null 14 null 30 16 null 20200622 

……….. ………. so on