SQL query in Pro-C fails with Error:02115 - sql

I am getting some weird behavior of Pro-C procedure as shown below:
#define BGHCPY_TO_ORA(dest, source) \
{ \
(void)strcpy((void*)(dest).arr, (void*)(source)); \
(dest).len = strlen((const char *)(dest).arr); \
}
#define BGHCPY_FROM_ORA(dest, source) \
{ \
(void)memcpy((void*)(dest), (void*)(source).arr, (size_t)(source).len); \
(dest)[(source).len] = '\0'; \
}
long fnSQLMarkProcessed (char *pszRowId, char *pszMarker)
{
BGHCPY_TO_ORA (O_rowid_stack, pszRowId);
BGHCPY_TO_ORA (O_cust_processed, pszMarker);
EXEC SQL
UPDATE document_all
SET processed_by_bgh = :O_cust_processed
WHERE rowid = :O_rowid_stack;
return (sqlca.sqlcode);
}
The input arguments values passed to above function is
pszRowId = [AAAF1lAAIAABOoRAAB], pszMarker=X
The query return the error code:02115 with following message:
SQL Error:02115 Code interpretation problem -- check COMMON_NAME usage
I am using Oracle as the backend database.
Can anyone provide me information on what are the possible causes for this failed query?
Any help is highly appreciated.
Flags used during PRO-C Compilation is defined below:
------/u01/app/oracle/product/8.1.6/ORACLE_HOME/bin/proc `echo -Dbscs5 -Dsun5 -I/export/home/bscsobw/bscs6/src/CoreDumpIssue/final_Code_Fix_004641 -DNDEBUG -DSunOS53 -D_POSIX_4SOURCES -I/usr/generic++/generic++2.5.3.64_bit/include -DFEATURE_212298 -DBSCS_CONFIG -I/export/home/bscsobw/bscs6//src/bat/include -DFEATURE_00203808_GMD -DFEATURE_00241737 -DORACLE_DB_BRAND -I/u01/app/oracle/product/8.1.6/ORACLE_HOME/rdbms/demo -I/u01/app/oracle/product/8.1.6/ORACLE_HOME/precomp/public -I/export/home/bscsobw/bscs6/src/CoreDumpIssue/final_Code_Fix_004641/include -I../bat/include -DFEATURE61717 -DFEATURE52824 -DFEATURE56178 -DD236312_d -DSDP -g | sed -e 's/-I/INCLUDE=/g' -e 's/-D[^ ]=[^ ]*//g' -e 's/-D\([^ ]*\)/DEFINE=\1/g'` select_error=no DEFINE=FEATURE61717 DEFINE=FEATURE52824 DEFINE=FEATURE56178 \
lines=yes iname=bgh_esql.pc oname=bgh_esql.c lname=bgh_esql.lis

I think, you check this message:
[oracle#sb-rac02 ~]$ oerr sql 2115
02115, 00000, "Code interpretation problem -- check COMMON_NAME usage"
// *Cause: With PRO*FORTRAN, this error occurs if the precompiler option
// COMMON_NAME is specified incorrectly. **With other Oracle
// Precompilers, this error occurs when the precompiler cannot
// generate a section of code.**
// *Action: With Pro*FORTRAN, when using COMMON_NAME to precompile two or
// more source modules, make sure to specify a different common name
// for each module. With other Oracle Precompilers, if the error
// persists, call customer support for assistance.
So you can determine, that problem not in your variables.
Please, try use your code like this:
long fnSQLMarkProcessed (char *pszRowId, char *pszMarker)
{
BGHCPY_TO_ORA (O_rowid_stack, pszRowId);
BGHCPY_TO_ORA (O_cust_processed, pszMarker);
EXEC SQL UPDATE document_all
SET processed_by_bgh = :O_cust_processed
WHERE rowid = :O_rowid_stack;
return (sqlca.sqlcode);
}

Related

bitbake do_package_qa issue contains bad RPATH

I am clueless about an issue which i am facing.
During cross compiling one of the app, i am getting following error which is making no sense.
If someone can help me debug the issue, it would be really helpful.
ERROR: lib32-audiod-1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00 do_package_qa: QA Issue: package lib32-audiod-ptest contains bad RPATH /home/work/ashutosh.tripathi/o20_build/build-starfish/BUILD/work/o20-starfishmllib32-linux-gnueabi/lib32-audiod/1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00/audiod-1.0.0-161.jcl4tv.85 in file /home/work/ashutosh.tripathi/o20_build/build-starfish/BUILD/work/o20-starfishmllib32-linux-gnueabi/lib32-audiod/1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00/packages-split/lib32-audiod-ptest/opt/webos/tests/audiod/gtest_audiod
package lib32-audiod-ptest contains bad RPATH /home/work/ashutosh.tripathi/o20_build/build-starfish/BUILD/work/o20-starfishmllib32-linux-gnueabi/lib32-audiod/1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00/audiod-1.0.0-161.jcl4tv.85 in file /home/work/ashutosh.tripathi/o20_build/build-starfish/BUILD/work/o20-starfishmllib32-linux-gnueabi/lib32-audiod/1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00/packages-split/lib32-audiod-ptest/opt/webos/tests/audiod/gtest_audiod [rpaths]
ERROR: lib32-audiod-1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00 do_package_qa: QA run found fatal errors. Please consider fixing them.
ERROR: lib32-audiod-1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00 do_package_qa: Function failed: do_package_qa
ERROR: Logfile of failure stored in: /home/work/ashutosh.tripathi/o20_build/build-starfish/BUILD/work/o20-starfishmllib32-linux-gnueabi/lib32-audiod/1.0.0-161.jcl4tv.85-r26audiod-automation-10Feb_00/temp/log.do_package_qa.4873
ERROR: Task (virtual:multilib:lib32:/home/work/ashutosh.tripathi/o20_build/build-starfish/meta-lg-webos/meta-webos/recipes-multimedia/audiod/audiod.bb:do_package_qa) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2622 tasks of which 2608 didn't need to be rerun and 1 failed.
Here is the audiod recipe file:
DEPENDS = "glib-2.0 libpbnjson luna-service2 pmloglib luna-prefs boost pulseaudio"
RDEPENDS_${PN} = "\
libasound \
libasound-module-pcm-pulse \
libpulsecore \
pulseaudio \
pulseaudio-lib-cli \
pulseaudio-lib-protocol-cli \
pulseaudio-misc \
pulseaudio-module-cli-protocol-tcp \
pulseaudio-module-cli-protocol-unix \
pulseaudio-server \
"
WEBOS_VERSION = "1.0.0-161.open.12_49f981e4e5a599b75d893520b30393914657a4ae"
PR = "r26"
inherit webos_component
inherit webos_enhanced_submissions
inherit webos_cmake
inherit webos_library
inherit webos_daemon
inherit webos_system_bus
inherit webos_machine_dep
inherit gettext
inherit webos_lttng
inherit webos_public_repo
inherit webos_test_provider
# TODO: move to WEBOS_GIT_REPO_COMPLETE
WEBOS_REPO_NAME = "audiod-pro"
SRC_URI = "${WEBOS_PRO_GIT_REPO_COMPLETE}"
S = "${WORKDIR}/git"
EXTRA_OECMAKE += "${#bb.utils.contains('WEBOS_LTTNG_ENABLED', '1', '-DWEBOS_LTTNG_ENABLED:BOOLEAN=True', '', d)}"
EXTRA_OECMAKE += "-DAUDIOD_PALM_LEGACY:BOOLEAN=True"
EXTRA_OECMAKE += "-DAUDIOD_TEST_API:BOOLEAN=True"
FILES_${PN} += "${datadir}/alsa/"
FILES_${PN} += "/data"
FILES_${PN} += "${webos_mediadir}/internal"
I would like to thank the stackoverflow community for the help offered.
Adding the following flags helped resolve the issue.
Posting it here, so that others may get some benefit from it, if they ever face similar problem
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
Or, skipping RPATH also does the job:
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
worked also by adding following line into the recipe:
EXTRA_OECMAKE += "-DCMAKE_SKIP_RPATH=TRUE"
https://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#ref-classes-cmake

ESP32 SSL connection works when CA Certificate is a constant, but not when read from a file

I have the following Arduino code I'm using with an ESP32:
if(!SPIFFS.begin(true)) {
Serial.println("Error mounting SPIFFS.");
}
File file = SPIFFS.open("/root.cer");
if(!file) {
Serial.println("Error opening the file.");
}
Serial.println("CA Root certificate: ");
String ca_cert = file.readString();
Serial.println(ca_cert);
espClient.setCACert(ca_cert.c_str());
file.close();
This is the relevant code for loading a file and setting the WiFiClientSecure's CA certificate. This code does not work.
However, if I replace espClient.setCACert(ca_cert.c_str()); with espClient.setCACert(ROOTCERT); where ROOTCERT is defined as such:
#define ROOTCERT "-----BEGIN CERTIFICATE-----\n" \
"MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" \
"MSQwIgYDVQQ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jJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" \
"Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" \
"-----END CERTIFICATE-----\n"
The code works.
The ROOTCERT string is taken directly from the certificate file, so they must be identical.
The certificate file was downloaded and exported using Windows's certificate exporter. I've tried converting line endings to no avail.
EDIT: I've found a clue.
If I do the following:
String constString = ROOTCERT;
espClient.setCACert(constString.c_str());
It also does not work.
And I added this code:
if(strcmp(constString.c_str(), ROOTCERT))
Serial.println("Constant and converted string are equal.");
else
Serial.println("Constant and converted string are different.");
And it prints "Constant and converted string are different."
So it appears to be some kind of problem with how .c_str() does things? I have no idea what this could be, though. When printed to the console, the .c_str(), ROOTCERT and ca_cert Strings all appear IDENTICAL.
I am completely confused here.
Turns out I was using strcmp() incorrectly. Things are still not working.
After messing around, I fixed it.
So .c_str() is just another way of pointing to the internal buffer of the String object.
Somehow that was messing things up. Using this code fixed it.
char *dest;
dest = (char *)malloc(sizeof(char) * (ca_cert.length()+1));
strcpy(dest, ca_cert.c_str());
espClient.setCACert(dest);

Terraform template_file get pass all received variables to a function

is there in Terraforom in template_files a way to pass through all the received variables to other place?
I mean something similar than $# in bash.
For example:
resource "template_file" "some_template" {
template = "my_template.tpl")}"
vars {
var1 = "value1"
var2 = "value2"
}
}
and then from the rendered file:
#!/bin/bash
echo "Var1: ${var1}"
echo "Var2: ${var2}"
echo "But I want it in someway similar to this:"
for v in $#; do
echo "$v";
done
According to the documentation, no.
From https://www.terraform.io/docs/providers/template/d/file.html
Variables for interpolation within the template. Note that variables
must all be primitives. Direct references to lists or maps will cause
a validation error.
Primitives in terraform are string, number and boolean.
So it means you can not pass a hash or a list to group all the variables in one.
Use join and pass all the variables as one and parse/split them within a script (with tr/IFS tricks)
join("; ", [var.myvar1, var.myvar2, var.myvar3])
and then
IN="${allvars}"
IFS=';' read -ra ADDR <<< "$IN"
for i in "${ADDR[#]}"; do
echo "$i"
done

How and when and where jvm change the max open files value of Linux?

In linux there is a limit for max open files for every process of each login user, as below:
$ ulimit -n
1024
When I study java nio, I'd like to check this value. Because channel also is a file in Linux,I wrote a client code to create socketChannel continuely until throwing below exception:
java.net.SocketException: Too many open files
at sun.nio.ch.Net.socket0(Native Method)
at sun.nio.ch.Net.socket(Net.java:423)
at sun.nio.ch.Net.socket(Net.java:416)
at sun.nio.ch.SocketChannelImpl.<init>(SocketChannelImpl.java:104)
at sun.nio.ch.SelectorProviderImpl.openSocketChannel(SelectorProviderImpl.java:60)
at java.nio.channels.SocketChannel.open(SocketChannel.java:142)
But I found it till created about 4085 socketChannel, it will throw this exception. This number is more than 1024. Somebody told me jvm changed the value implicitly. And I wrote a java program to execute ulimit command, and found jvm do change the value. As below:
String [] cmdArray = {"sh","-c","ulimit -n"};
Process p = Runtime.getRuntime().exec(cmdArray);
BufferedInputStream in = new BufferedInputStream(p.getInputStream());
byte[] buf = new byte[1024];
int len = in.read(buf);
System.out.println(new String(buf, 0, len)); //4096
Does anybody know when and where and how jvm changes this value? Does exist some sys log to record this change or some sys tool could monitor this change?
$ strace -f -o HelloWorld.strace java HelloWorld
Hello World!
$ vi HelloWorld.strace
...
16341 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0
16341 setrlimit(RLIMIT_NOFILE, {rlim_cur=4*1024, rlim_max=4*1024}) = 0
...
Download openjdk, then cd into hotspot dir,
$ grep -r setrlimit
...
src/os/linux/vm/os_linux.cpp: status = setrlimit(RLIMIT_NOFILE, &nbr_files);
...
$ vi src/os/linux/vm/os_linux.cpp
...
if (MaxFDLimit) {
// set the number of file descriptors to max. print out error
// if getrlimit/setrlimit fails but continue regardless.
struct rlimit nbr_files;
int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
if (status != 0) {
if (PrintMiscellaneous && (Verbose || WizardMode))
perror("os::init_2 getrlimit failed");
} else {
nbr_files.rlim_cur = nbr_files.rlim_max;
status = setrlimit(RLIMIT_NOFILE, &nbr_files);
if (status != 0) {
if (PrintMiscellaneous && (Verbose || WizardMode))
perror("os::init_2 setrlimit failed");
}
}
...
If you modify above code, e.g.
//nbr_files.rlim_cur = nbr_files.rlim_max;
nbr_files.rlim_cur = 2048;
then rebuild this openjdk, then use this new jdk to execute above code, you'll find the output is 2048.

How to set default values for Tcl variables?

I have some Tcl scripts that are executed by defining variables in the command-line invocation:
$ tclsh84 -cmd <script>.tcl -DEF<var1>=<value1> -DEF<var2>=<value2>
Is there a way to check if var1 and var2 are NOT defined at the command line and then assign them with a set of default values?
I tried the keywords global, variable, and set, but they all give me this error when I say "if {$<var1>==""}": "can't read <var1>: no such variable"
I'm not familiar with the -def option on tclsh.
However, to check if a variable is set, instead of using 'catch', you can also use 'info exist ':
if { ![info exists blah] } {
set blah default_value
}
Alternatively you can use something like the cmdline package from tcllib. This allows you to set up defaults for binary flags and name/value arguments, and give them descriptions so that a formatted help message can be displayed. For example, if you have a program that requires an input filename, and optionally an output filename and a binary option to compress the output, you might use something like:
package require cmdline
set sUsage "Here you put a description of what your program does"
set sOptions {
{inputfile.arg "" "Input file name - this is required"}
{outputfile.arg "out.txt" "Output file name, if not given, out.txt will be used"}
{compressoutput "0" "Binary flag to indicate whether the output file will be compressed"}
}
array set options [::cmdline::getoptions argv $sOptions $sUsage]
if {$options(inputfile) == ""} {puts "[::cmdline::usage $sOptions $sUsage]";exit}
The .arg suffix indicates this is a name/value pair argument, if that is not listed, it will assume it is a binary flag.
You can catch your command to prevent error from aborting the script.
if { [ catch { set foo $<var1> } ] } {
set <var1> defaultValue
}
(Warning: I didn't check the exact syntax with a TCL interpreter, the above script is just to give the idea).