Empty result when running DDL migration - flyway

I am working on adding (back) support for Apache Phoenix (at least for our own usage, looks like it was pulled a few years ago) on top of the latest version of Flyway. I wrote a real small script to create a table, and am running migrate.
I see that the table gets created on my database, but in JdbcTemplate#executeStatement(), at line statement.execute(sql) returns null. Then, in extractResults(), it gets into an infinite loop at this line:
while (hasResults || (updateCount = statement.getUpdateCount()) != -1) {
Since statement.getUpdateCount() is 0 (no rows updated on table creation), it just loops until I run out of memory. I'm sure I'm just missing something real simple but can't find it.

Related

problem iterating on an empty dictionary Delphi 10.4

I have the following code with two dictionaries. I can see that when I iterate through DictForbidden even though it is empty the execution flow enters the loop so DictToAdd.remove(anInteger); is executed with
the old value of anInteger
var DictForbidden, DictToAdd : TDictionary<Integer,boolean>;
var anInteger: Integer;
DictForbidden := TDictionary<Integer,boolean>.Create;
DictToAdd := TDictionary<Integer,boolean>.Create;
anInteger := 1;
DictToAdd.Add(anInteger,true);
for anInteger in DictForbidden.Keys do
DictToAdd.remove(anInteger);
DictForbidden.Free;
DictToAdd.Free;
I am running Delphi 10.4 and I don't recall such a behavior in 10.3. I think back then if the dictionary was empty the loop was not entered. Do you know if this is something new on Delphi 10.4?, or maybe I am doing something wrong here?
regards, Carlos
In my 10.4.1 it doesn't enter the loop. But it may look like it does when you debug trace due to optimization made by the compiler. Try replacing the
DictToAdd.Remove
with a
writeln(anInteger) // if Console Application
ShowMessage(IntToStr(anInteger)) // if GUI Application
and see if anything is reported.
thank you very much for the quick help!
Actually you are right #Heartware. After the loop, DictToAdd still contains a 1. So basically there is no case here rather than putting a break point in the line DictToAdd.remove(anInteger); the execution is stopped and putting then the cursor above anInteger you see the value is 1 but stepping over the 1 is not being removed. When replacing the removal by a showmessage I observe the same thing the break point is reached but the showmessage is not executed.
Also noticed that when using a begin/end like this
for anInteger in DictForbidden.Keys do
begin
DictToAdd.remove(anInteger);
end;
the break point is not reached.
This is a little annoyance with the debugger caused by the fact that a loop of course produces some executable code - especially a for in loop that has calls to MoveNext and Current and some cleanup code for the enumerator after it completes.
This code has to go somewhere and often the line information being used by the debugger (aka "the blue dots") of that code overlap with actual code you wrote like in this case.
To illustrate this here is how the disassembly looks like when I put your code into a console application.
As you can see there are two breakpoints displayed here which belong to the same one breakpoint I placed in line 21. But the one that got hit is the one with the cleanup code which is responsible for destroying the enumerator. If you hit F7 and you compiled with debug dcus you will notice that it actually does not go into TDictionary.Remove but into TObject.Destroy.
Now the disassembly after placing the begin and end:
Again two breakpoints shown but this time I actually placed them both myself - and they are for different lines.

Table methods not working anymore

I have a table with different methods, for example, one of them is validateWrite, when setting Field A to value X, Field B and C has to be filled in.
Suddenly (without changing code, I have compared the code with the test enviroment, it does work there) the validateWrite has stopped working.
I have tried to recompile the table, but that did not work.
Any idea why it suddenly (without making other modifications in this enviroment, or generating a CIL) stopped working and what i can try to solve it?
If some piece of code is calling table.doInsert(), it skips the validateWrite() method.
If the environments are truly identical, then I would try closing your AX client and deleting your user caches (see http://dynamics-ax-live.blogspot.com/2010/03/more-information-about-auc-file.html) where you delete all of the *.auc files located at C:\Users\[Username]\AppData\Local
In addition to what that tells you to delete, I'd also remove the *.kti file and all of the files & folders inside of C:\Users\[UserName]\AppData\Local\Microsoft\Dynamics Ax
Then open AX, see if the problem still exists. Then full system compile, CIL build, and delete your usage data.
The preferred route though would be to just drop a breakpoint in and debug the code to see what the execution stack is.

File Exists and Exception Handling in U-Sql

Two questions
How to check file exists or not before EXTRACT?
we have scenario where new inputs file is generated every day for catalog data. we need to merge new input with d-1 file. before merge we what to make sure that new input file exists at source location
does u-sql supports try...catch block?
Regarding checking if a file exists. We recently released a compile-time IF statement that indeed can check for partition existence (and other objects such as files and tables are on the roadmap).
Once that feature is released (still one or two refreshs out at the time of this answer) it may look something like (syntax subject to change):
IF FILE.EXISTS("/mydir/myfile.csv") THEN
#data = EXTRACT ... FROM "/mydir/myfile.csv" USING ...;
...
#jobstate = SELECT * FROM (VALUES("job completed")) AS T(status);
ELSE
#jobstate = SELECT * FROM (VALUES("file not ready. Job not executed.")) AS T(status);
END;
OUTPUT #jobstate TO "/jobs/myjobstate.csv" USING Outputters.Csv();
You will be able to provide the name as a parameter as well. Please let me know if that will work for your scenario.
An other alternative is to use the file set syntax, especially if you want to use a dynamic value to determine the process. That would simply create an empty rowset:
#data = EXTRACT ..., date DateTime
FROM "/mydir/{date:yyyy}/{date:MM}/{date:dd}/data.csv"
USING ...;
#data = SELECT * FROM #data WHERE date == DateTime.Now.AddDays(-1);
... // continue processing #data that is empty if yesterday's file is not yet there
Having said that, you may want to check of your job orchestration framework (such as ADF) may be a better place to check for existence before submitting the job in the first place.
As to the try catch block: U-SQL itself is a script-level optimizable, declarative language where the plan gets generated and optimized at runtime over the whole script. Thus providing a dynamic TRY-CATCH is currently not available, since it would severely impact the ability to optimize the script (e.g., you cannot move predicates or column pruning outside of a try-catch block). Also TRY/CATCH can lead to some very hard to understand and debug code, especially if it is used to mimic procedural workflows in an otherwise declarative environment.
However, you can use try/catch inside your C# functions without problems if you need to catch C# runtime errors.
FILE.EXISTS() always returns True when executed locally. However, it works when executing against Azure Data Lake.
Tried MSDN example and the following returns True, True
DECLARE #filepath_good = "/Samples/Data/SearchLog.tsv";
DECLARE #filepath_bad = "/Samples/Data/zzz.tsv";
#result =
SELECT FILE.EXISTS(#filepath_good) AS exists_good,
FILE.EXISTS(#filepath_bad) AS exists_bad
FROM (VALUES (1)) AS T(dummy);
OUTPUT #result
TO "/Output/FileExists.txt"
USING Outputters.Csv();
I have Microsoft Azure Data Lake Tools for Visual Studio version 2.2.5000.0

Qt::QTableWidget->setRowCount(0) crashes the application in release build?

I have a QTableWidget with 3 columns and 1000 rows (depends on the number of fetched items from the database ).
I also have a "Reload" Button to reload all the items from the database.
In "Reload" button, I want to delete all the rows from QTableWidget before loading items from the database.
Deleting all rows from the QTableWidget crashes the application when rowcount = 1.
I am using following logic to delete all the rows.
if( ui->tableWidget->rowCount() > 0)
{
ui->tableWidget->setRowCount(0);
}
also tried below logic
while (ui->tableWidget->rowCount() > 0)
{
ui->tableWidget->removeRow(0);
}
My application crashes using either of the logic when rowCount = 1.
It happens only when i build my application in release mode while it works fine in debug mode.
Can i get any idea why my application is getting crash.
I had the same problem, from one day to another it stopped working and I couldn't find what part of my code was making my program crash.
My program was used for reading files from a folder and uploading the file information into a QTableWidget, and I was also using cellWidgets for some information.
These are the problems that came to my mind, you should check that they're not happening to you:
The program was modifying the table all the time, so maybe i was trying to access an empty table. So I commented the lines where I was calling the table row and debugged it, but this wasn't a problem.
It could be a debugger problem, so I tried building it in Release and Profile mode, but still didn't work.
I could be having a problem when trying to access the cellWidget information, so I checked and I wasn't trying to access it.
Maybe the problem was when I was trying to eliminate a row that had a cellWidget, so I tried using ui->tableWidget->clearContents() before setting the row count to 0, (Didn't work)
After trying all of these I came upon this post. And basically I replaced setRowCount(0) with it's internal implementation ui->table->model()->removeRows(0,ui->table->rowCount());, debugged it and it worked.

SQL Server Deploy Script

I use sql server 2005 for an asp.net project. I want to run a SQL file that contains all DB changes from the last release to easily bring a DB up to the latest version.
I basically just have a bunch of alter table, create table, create index, alter view, call stored proc, etc statements. But I would like to wrap it in a transaction so if any part of it fails, none of the changes will go through. Otherwise it could make for some really messy debugging where it finished.
Also, if you know of a better way to manage DB deployment let me know!
I do something similar with a Powershell script using SMO.
Pseudocode would be:
$SDB = SourceDBObject
$TDB = TargetDBObject
ForEach $table in $SDB.Tables
{
Add an entry to a hash table with the name
and some attributes (rowcount, columns, datasize)
}
# Same thing for $TDB
# Compare the two arrays, and make a list of all the ones that exist in the source but not in the target, or that are different
# Same thing for Procs and Views
# Pass this list to a SMO.Scripter as an UrnCollection object, and it will script them out in dependency order (it's an option), with drops
# Wrap the script in a transaction and execute it on target server
# Use SQLBulkCopy class to transfer data server-to-server
What version of Visual Studio do you use? In Visual Studio 2010 and from what I can remember Visual Studio 2008 - in the menu under "Data" there are two options - "Schema Compare" and "Data Compare". That should move you in the right direction.
BEGIN TRANSACTION #TranName;
USE AdventureWorks2008R2;
DELETE FROM AdventureWorks2008R2.HumanResources.JobCandidate
WHERE JobCandidateID = 13;
COMMIT TRANSACTION #TranName;
You should execute everything within a transaction
Note that some DDL statements have to be the first statement in a batch (batches are separate from transactions). (GO is the default batch separator in SSMS and SQLCMD).

Resources