Do not get result for all sqlite pragmas via QSqlQuery - linux

I want to get the current states of sqlite pragma using Qt's QSqlQuery.
But I do not get a result for some values from the program but from sqlite console.
Qt version 5.2.1, Sqlite version 3.8.4.3, Windows 7, Ubuntu 12.4 LTS
Output:
application_id = "0"
auto_vacuum = "0"
automatic_index = "1"
busy_timeout = "5000"
cache_size = "2000"
cache_spill = [NoResult]
case_sensitive_like = [NoResult]
void MySqliteInfo::PrintState(QString state)
{
printf("%s = ", state.toStdString().c_str());
QSqlQuery query(*m_db);
query.prepare(QString("PRAGMA %1").arg(state));
query.exec();
if(0 == query.size()) {
printf("%s returns nothing\n", state.toStdString().c_str());
}
else {
if(query.next()) {
QVariant value = query.value(0);
if(value.canConvert(QMetaType::QString)) {
printf("\"%s\"\n", value.toString().toStdString().c_str());
}
else {
printf("[UnknownDataType]\n");
}
}
else {
printf("[NoResult]\n");
}
}
query.finish();
}
PrintState("application_id");
PrintState("auto_vacuum");
PrintState("automatic_index");
PrintState("busy_timeout");
PrintState("cache_size");
PrintState("cache_spill");
PrintState("case_sensitive_like");

The SQLite version that you are actually using in your Qt program does not yet implement PRAGMA cache_spill.
SQLite just ignores any PRAGMA it does not recognize.
As documented, PRAGMA case_sensitive_like does not allow reading the current value.

First of all, the query.size() test ist useless, since it returns -1 for every value. query.size() can only be used with SELECT queries.
Now [NoResult] can have two different meanings:
A pragma value does not exist
A pragma value is Not Set
In an example database created from another program, I observe the first case for cache_spill and the second case for case_sensitive_like. You might want to check the values using sqliteman on Ubuntu.

I found the solution tt least for cache_spill:
The used sqlite3.exe supports pragma cache_spill but not the sqlite version comes with Qt 5.2. (3.7.17).
Qt 5.3 comes with Sqlite 3.8.4.3 - the git repro says this.

Related

Apache poi 5.2.2 string cell type

In the documentation, from apache poi 5 cell.setCellType is deprecated, and according to the documentation, the library will handle different types itself, but i have the strange thing that is happening. When i try to put a string into a cell i always have (after i open the excel) a number type inside of the cell it instead text, no matter which implementation of workbook i`m using. I have tried with all available and the result is the same. So i took a look of implementation of XSSFCell(because currently i use XSSFWordBook) and i saw the following:
CellType cellType = getCellType();
if (cellType == CellType.FORMULA) {
_cell.setV(str.getString());
_cell.setT(STCellType.STR);
} else {
if(_cell.getT() == STCellType.INLINE_STR) {
//set the 'pre-evaluated result
_cell.setV(str.getString());
} else {
_cell.setT(STCellType.S);
XSSFRichTextString rt = (XSSFRichTextString)str;
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addSharedStringItem(rt);
_cell.setV(Integer.toString(sRef));
}
}
so it always convert the text into "RichTextString" object, and after that it is entering
in the else condition. Can someone explain me how i can put the type of the cell to be
STCellType.INLINE_STR
in order to avoid this converting to Integer.
P.S. keep in mind that also tried to use the deprecated
setCellType
and again it is converted to integer or it is entering in the else code block

Where is kernel machine_desc table information?

I'm trying to understand how devicetrees work.
According to the kernel documentation, they are used, in arm architecture, in the following manner:
In the majority of cases, the machine identity is irrelevant, and the kernel will instead select setup code based on the machine’s core CPU or SoC. On ARM for example, setup_arch() in arch/arm/kernel/setup.c will call setup_machine_fdt() in arch/arm/kernel/devtree.c which searches through the machine_desc table and selects the machine_desc which best matches the device tree data. It determines the best match by looking at the ‘compatible’ property in the root device tree node, and comparing it with the dt_compat list in struct machine_desc (which is defined in arch/arm/include/asm/mach/arch.h if you’re curious).
The ‘compatible’ property contains a sorted list of strings starting with the exact name of the machine, followed by an optional list of boards it is compatible with sorted from most compatible to least.
I found the source code related to the comparison of machine_desc to the compatible parameter set in the dts file:
const struct machine_desc * __init setup_machine_fdt(void *dt_virt)
{
const struct machine_desc *mdesc, *mdesc_best = NULL;
#if defined(CONFIG_ARCH_MULTIPLATFORM) || defined(CONFIG_ARM_SINGLE_ARMV7M)
DT_MACHINE_START(GENERIC_DT, "Generic DT based system")
.l2c_aux_val = 0x0,
.l2c_aux_mask = ~0x0,
MACHINE_END
mdesc_best = &__mach_desc_GENERIC_DT;
#endif
if (!dt_virt || !early_init_dt_verify(dt_virt))
return NULL;
mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
if (!mdesc) {
const char *prop;
int size;
unsigned long dt_root;
early_print("\nError: unrecognized/unsupported "
"device tree compatible list:\n[ ");
dt_root = of_get_flat_dt_root();
prop = of_get_flat_dt_prop(dt_root, "compatible", &size);
while (size > 0) {
early_print("'%s' ", prop);
size -= strlen(prop) + 1;
prop += strlen(prop) + 1;
}
early_print("]\n\n");
dump_machine_table(); /* does not return */
}
/* We really don't want to do this, but sometimes firmware provides buggy data */
if (mdesc->dt_fixup)
mdesc->dt_fixup();
early_init_dt_scan_nodes();
/* Change machine number to match the mdesc we're using */
__machine_arch_type = mdesc->nr;
return mdesc;
}
However, I didn't find machine_desc table definition.
If I'd like to read all machine_desc, Where can I find it?
TL;DR - The machine description is built by building and linking different source files into the kernel. So each machine source file adds an entry into the table.
The table is based in arch/arm/kernel/vmlinux.lds.S (or relevant architecture linker file). It is built with the macros MACHINE_START and MACHINE_END. This places a structure in the 'arch.info.init' sections of the object file. All of these objects get globbed together by the linker. This forms the table. So, it is constructed by linking different source files with the MACHINE_START and MACHINE_END macros. Therefore, it doesn't exist in one place.
However, you can use git grep -A10 MACHINE_START to get a fairly good list. This command works well, as typically, it is the last thing in the file so only five or six lines may print. Or you could write init code to dump the table by printing the machine_desc entries.
That said, the table is not too interesting as it is just function pointers to call at different times. The majority will be NULL as it used designated initializers.
Related: Control to 'dt_machine_start' on Android

Passing params to V93K test_suites.add method

This is in reference to this question. I checked our test interface and we are only passing the V93k primary params to the test_suites.add method.
V93K_PRIMARIES = [:lev_equ_set, :lev_spec_set, :timset, :tim_equ_set, :tim_spec_set, :seqlbl, :levset]
primary_tm_params = {}.tap do |primary_hash|
V93K_PRIMARIES.each do |param|
primary_hash[param] = tm_params.delete(param) unless tm_params[param].nil?
end
end
# Create the test suite
t = test_suites.add(test_name, primary_tm_params)
t.test_method = test_methods.amd93k.send(options[:tm].to_sym, tm_params)
V93K_PRIMARIES.each do |primary|
t.send("#{primary}=", primary_tm_params[primary]) unless primary_tm_params[primary].nil?
end
# Insert the test into the flow
test(t, tm_params)
When I set a breakpoint, I do see they were missing. Here they are after updating the code:
:ip=>:L2,
:testmode=>:speed,
:cond=>:pmax,
:if_failed=>:cpu_pmin,
:testtype=>:cpu,
:test_ip=>:bist,
:tm=>"Bist"}
And here is the .tf file generated from the original two tests in the original question:
run_and_branch(cpu_L2_speed_pmin_965EA18)
then
{
}
else
{
#CPU_PMIN_965EA18_FAILED = 1;
}
if #CPU_PMIN_965EA18_FAILED == 1 then
{
run(cpu_L2_speed_pmax_965EA18);
}
else
{
}
I think we have it figured out, thx very much!
The normal approach to this is just to pass everything to flow.test, rather than a subset of the options passed from the flow.
It will only act on the options it recognizes, which are basically the flow control parameters (:id, :if_failed, :unless_enabled, etc) and the test and bin number parameters, and it will just ignore the rest.

IsolatedStorage.GetFileNames fails on MonoTouch/MonoDroid

I was trying out MonoTouch/MonoAndroid and everything was going
well until I called IsolatedStorageFile.GetFileNames(string) function. The
parameter was "Foo/Foo1/*". The result is SecurityException with no message.
The directory "Foo/Foo1" exists, because it has just been found using IsolatedStorageFile.GetDirectoryNames() call.
I identified this bit in Mono sources that throws the exception (in IsolatedStorageFile.cs):
DirectoryInfo[] subdirs = directory.GetDirectories (path);
// we're looking for a single result, identical to path (no pattern here)
// we're also looking for something under the current path (not
outside isolated storage)
if ((subdirs.Length == 1) && (subdirs [0].Name == path) && (subdirs[0].FullName.IndexOf(directory.FullName) >= 0)) {
afi = subdirs [0].GetFiles (pattern);
} else {
// CAS, even in FullTrust, normally enforce IsolatedStorage
throw new SecurityException ();
}
I can't step into it with the debugger so I don't know why the
condition is false. This happens both on iOS and Android. There was a
similar issue logged long time ago at
http://www.digipedia.pl/usenet/thread/12492/1724/#post1724, but there
are no replies.
The same code works on Windows Phone 7 without problems (with \ for path separators).
Has anyone got any ideas what might be causing it? Is it the uppercase in
directory names a problem?
It is a bug in Mono. IsolatedStorage will not work with paths that contain more than one directory in a row (such as Foo/Foo1/*)
I copied the code of GetFileNames() method from Mono to my project so that I can debug it. I found out that the problem is in the 2nd term of this condition (IsolatedStorageFile.cs:846):
if ((subdirs.Length == 1) && (subdirs [0].Name == path) &&(subdirs[0].FullName.IndexOf(directory.FullName) >= 0)) {
afi = subdirs [0].GetFiles (pattern);
} else {
// CAS, even in FullTrust, normally enforce IsolatedStorage
throw new SecurityException ();
}
For example when path passed to GetFileNames() is "Foo/Bar/*", subdirs[0].Name will be "Bar" while path will be "Foo/Bar" and the condition will fail causing the exception.

UUID Cassandra

I am new to Cassandra. I am trying to insert some values to the columnfamily. The definition of columnfamily in the config file is as follows.
<ColumnFamily Name="CommandQueue"
ColumnType="Super"
CompareWith="TimeUUIDType"
CompareSubcolumnsWith="UTF8Type"/>
When ever I try to insert values to I always get "InvalidRequestException(why: UUIDs must be exactly 16 bytes)".
I am using batch_mutate() to insert column.
How can I insert values to the column family.
"We have an API for that" :-)
https://github.com/rantav/hector/blob/master/core/src/main/java/me/prettyprint/cassandra/utils/TimeUUIDUtils.java
This class makes it easy to build type1 UUIDs and extract the timestamps as needed. See the related test case for examples.
Hector is MIT licensed, so if you are set on doing your own thing, feel free to use whatever helps.
Below is a code snippet (from Nick Berardi's Coder Journal)
public static Guid GenerateTimeBasedGuid(DateTime dateTime)
{
long ticks = dateTime.Ticks - GregorianCalendarStart.Ticks;
byte[] guid = new byte[ByteArraySize];
byte[] clockSequenceBytes = BitConverter.GetBytes(Convert.ToInt16(Environment.TickCount
% Int16.MaxValue));
byte[] timestamp = BitConverter.GetBytes(ticks);
// copy node
Array.Copy(Node, 0, guid, NodeByte, Node.Length);
// copy clock sequence
Array.Copy(clockSequenceBytes, 0, guid, GuidClockSequenceByte,clockSequenceBytes.Length);
// copy timestamp
Array.Copy(timestamp, 0, guid, 0, timestamp.Length);
// set the variant
guid[VariantByte] &= (byte)VariantByteMask;
guid[VariantByte] |= (byte)VariantByteShift;
// set the version
guid[VersionByte] &= (byte)VersionByteMask;
guid[VersionByte] |= (byte)((int)GuidVersion.TimeBased << VersionByteShift);
return new Guid(guid);
}
I am just continuing where "Schildmejir" has stopped. This how you can actually use the generated GUID in inserting values to columnfamilies.
Mutation foobar = new Mutation()
{
Column_or_supercolumn = new ColumnOrSuperColumn()
{ Super_column = new SuperColumn()
{ Name = GuidGenerator.GenerateTimeBasedGuid(DateTime.Now).ToByteArray(),
Columns = listOfSomeColumns
}
}
};
List<Column> foobarlist = new List<Column>();
listOfChannelIds.Add(new Column() { Name = utf8Encoding.GetBytes("somename"), Value = utf8Encoding.GetBytes(somestring), Timestamp = timeStamp });
You can use the generated GUID either in SupercolumnName or columnName depending on the requirement.
Cassandra expects UUIDs to conform to RFC 4122, so you'll need to either generate compliant values yourself or use an existing library for the language of your choice (most languages have free UUID generation libraries readily available).

Resources