SQLite3 BaseFunction-Include for Win + Lin + Unicode
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
I tried with that include, no joy. The "SQliteGetTable" method works, the "SQLitePrepare" doesn't.Kiffi wrote:this one: http://www.purebasic.fr/english/viewtop ... 667#194667?Fangbeast wrote:I'm using an older include
Testing this include with your snippet and PB 4.1 also
works fine and no error occurred
Greetings ... Kiffi
Just thinking about what Paul Dwyer said about database conversion and types etc and that error message ""ERROR, specified address is null"
When I first created my database a year ago, I was using pb4.x and the latest sqlite dll at that time and getting those errors all the time until someone pointed out that I should be doing this:
PeekS(MyData, #PB_Any, #PB_Ascii)
I wasn't using Unicode in either the compiler or the database at the time and doing that to PEEKS cured it, no more address is null errors.
Does this give you any ideas? Because I have no clue (lol) !
@Fangbeast:
first of all: check out if this code works for you:
http://test.tuebben.de/protozoa.zip
(this zip includes the pb-source and a sample-database)
If the code works without any problems, you have to check
if your database is broken.
Greetings ... Kiffi
first of all: check out if this code works for you:
http://test.tuebben.de/protozoa.zip
(this zip includes the pb-source and a sample-database)
If the code works without any problems, you have to check
if your database is broken.
Greetings ... Kiffi
Hygge
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
You are not going to believe this
I pass this path to the sqlite include to OpenLibrary and it's always worked for me in the past. It works when using GetTable but not for prepare
"\Development\Resources\Libraries\sqlite3upx.dll"
As soon as I put the drive letter in, it works for Prepare as well??
"C:\Development\Resources\Libraries\sqlite3upx.dll"
Why in hell does a drive letter make a difference to using the lib in the "prepare.
=================================================
Works fine with your database but not with mine. No matter what I do, only the GetTable method works.
Thanks for trying Kiffi, at least my old sqlite code works still and so does the GetTable method with Thomas's and your include, so I know my database isn't broken.
I think I'd better give up before my hair turns white!
"\Development\Resources\Libraries\sqlite3upx.dll"
As soon as I put the drive letter in, it works for Prepare as well??
"C:\Development\Resources\Libraries\sqlite3upx.dll"
Why in hell does a drive letter make a difference to using the lib in the "prepare.
=================================================
Works fine with your database but not with mine. No matter what I do, only the GetTable method works.
Thanks for trying Kiffi, at least my old sqlite code works still and so does the GetTable method with Thomas's and your include, so I know my database isn't broken.
I think I'd better give up before my hair turns white!
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Using the 4.2 specific includes with new code and encountered an error when an empty string is sent to the query. Error is "Specified Address is Null"
Should I bulletproof my routine to NOT send an empty string to the query or should this routine be bulletproofed?
Should I bulletproof my routine to NOT send an empty string to the query or should this routine be bulletproofed?
Code: Select all
Procedure.s SQLiteColumnText(lStatement.l, lColumn.l)
CompilerIf #PB_Compiler_Unicode
ProcedureReturn PeekS(sqlite3_column_text16(lStatement, lColumn))
CompilerElse
ProcedureReturn PeekS(sqlite3_column_text(lStatement, lColumn));<< this one throws up that error.
CompilerEndIf
EndProcedure
Only the special tablefunctions have a test on it, the other routines only
wrappers, but i will add a nullpointercheck for functions with Stringresult.
greetings
Thomas
// edit:
done
http://www.purebasic.fr/english/viewtop ... 853#240853
wrappers, but i will add a nullpointercheck for functions with Stringresult.
greetings
Thomas
// edit:
done
http://www.purebasic.fr/english/viewtop ... 853#240853
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Hi Thomas, I wasn't sure if I was right or wrong so did some more testing. It seems I can crash it by just sending a single space character. Is that equivalent to a null somehow?ts-soft wrote:Only the special tablefunctions have a test on it, the other routines only
wrappers, but i will add a nullpointercheck for functions with Stringresult.
greetings
Thomas
// edit:
done
http://www.purebasic.fr/english/viewtop ... 853#240853
I can't add a check is query okay, sry
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
I created an extra column in my database with a professional tool and when this code gets to it, it crashes. It must have created the column with null values by default but there is no way for me to examine the column contents that I know of.
How can I bulletproof this procedure so that it doesn't crash with "Specified address is null" as it must be hitting a null in that column?
How can I bulletproof this procedure so that it doesn't crash with "Specified address is null" as it must be hitting a null in that column?
Code: Select all
Procedure.s SQLiteColumnText(lStatement.l, lColumn.l)
CompilerIf #PB_Compiler_Unicode
If SQ3\column_text16
ProcedureReturn PeekS(SQ3\column_text16(lStatement, lColumn))
EndIf
CompilerElse
If SQ3\column_text
ProcedureReturn PeekS(SQ3\column_text(lStatement, lColumn))
EndIf
CompilerEndIf
ProcedureReturn ""
EndProcedure
What about sticking in a If SQ3\column_text(lStatement, lColumn) before the PeekS() etc. or have I misunderstood?
Code: Select all
Procedure.s SQLiteColumnText(lStatement.l, lColumn.l)
CompilerIf #PB_Compiler_Unicode
If SQ3\column_text16 And SQ3\column_text16(lStatement, lColumn)
ProcedureReturn PeekS(SQ3\column_text16(lStatement, lColumn))
EndIf
CompilerElse
If SQ3\column_text And SQ3\column_text(lStatement, lColumn)
ProcedureReturn PeekS(SQ3\column_text(lStatement, lColumn))
EndIf
CompilerEndIf
ProcedureReturn ""
EndProcedure
I may look like a mule, but I'm not a complete ass.
Well PeekS() will crash if you supply it with a null address and your SQLite wrapper there returns a null pointer in the cases where there is no text in the field etc. Put the two together and, without the checks introduced above, you end up using PeekS() on a null address ... crash!!!


I may look like a mule, but I'm not a complete ass.
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
[SOLVED]
How do I modify the below code so that it returns all my text? If I save a block of text with invisible CR/LF pairs, I can check that the data is in fact in the database (with a professional SQL tool) but when I retrieve the text, it is truncated at the first CR/LF encountered as if it were a null char?
*EDIT* It wasn't the routine at all. it was the fact that there were CR/LF pairs (0D0A) in one field, and I was sending the returned data to a ListIconGadget which uses 0A (CHR(10)) to separate the columns and thus truncating the data and messing up the display.
ARRGHGHGHGH!!!
Code: Select all
Procedure.s SQLiteColumnText(lStatement.l, lColumn.l)
CompilerIf #PB_Compiler_Unicode
If SQ3\column_text16
ProcedureReturn PeekS(SQ3\column_text16(lStatement, lColumn))
EndIf
CompilerElse
If SQ3\column_text
ProcedureReturn PeekS(SQ3\column_text(lStatement, lColumn))
EndIf
CompilerEndIf
ProcedureReturn ""
EndProcedure
ARRGHGHGHGH!!!