> I have a question about C binding for sqlite. I have seen those for > integer, float... but I was wondering how to deal with a NUMERIC (x, y) > type ? > We can't use float or double, we could loose precision, so maybe with a > string ?
I have a question about C binding for sqlite, I have a table like this: Name Price1 Price2 Sum A1 23 231 A2 22 12 A3 21 223 how to use functin int sum(price1+price2) result to put into sum cloumn use sqlite in c code? -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of sqlite-users-requ...@sqlite.org Sent: Thursday, December 22, 2011 1:00 AM To: sqlite-users@sqlite.org Subject: sqlite-users Digest, Vol 48, Issue 21 Send sqlite-users mailing list submissions to sqlite-users@sqlite.org To subscribe or unsubscribe via the World Wide Web, visit http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users or, via email, send a message with subject or body 'help' to sqlite-users-requ...@sqlite.org You can reach the person managing the list at sqlite-users-ow...@sqlite.org When replying, please edit your Subject line so it is more specific than "Re: Contents of sqlite-users digest..." Today's Topics: 1. Re: Strange behavior for timeouts in transactions (romtek) 2. Re: How about the way put a database of SQLite 3 beside web folder? (romtek) 3. Re: Strange behavior for timeouts in transactions (Simon Slavin) 4. insert error (jim-on-linux) 5. Re: insert error (Petite Abeille) 6. Re: insert error (epank...@comcast.net) 7. Re: Procedure (Conditional statement) workaround (Nico Williams) 8. Re: Procedure (Conditional statement) workaround (Petite Abeille) 9. run a script in Visual Basic.NET (Esteban Cervetto) 10. Re: run a script in Visual Basic.NET (Simon Slavin) 11. sqlite3_column_text() returning partial results (Jacob A. Camp) 12. Re: sqlite3_column_text() returning partial results (Igor Tandetnik) 13. Re: sqlite3_column_text() returning partial results (nobre) 14. Re: sqlite3_column_text() returning partial results (Simon Slavin) 15. Re: Bug in trigger: when comparing a value of an int column to a quoted value (Alexey Pechnikov) 16. sqlite3_column_text() returning partial results (Jake) 17. Re: sqlite3_column_text() returning partial results (Igor Tandetnik) 18. Re: sqlite3_column_text() returning partial results (Jacob A. Camp) 19. Re: sqlite3_column_text() returning partial results (Black, Michael (IS)) 20. Re: sqlite3_column_text() returning partial results (Pavel Ivanov) ---------------------------------------------------------------------- Message: 1 Date: Tue, 20 Dec 2011 11:21:16 -0600 From: romtek <rom...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] Strange behavior for timeouts in transactions Message-ID: <caaqe0hykz4p_qhv6x3gaffnxfolqe0tqkipsqbsi3mlb19s...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Tue, Dec 20, 2011 at 6:08 AM, Simon Slavin <slav...@bigfraud.org> wrote: > > First, there's more than one way of using SQLite3 from PHP. ?There's also the > interface SQLite3:: which is a much thinner wrapper around the basic SQLite C > library. ?I have no way of knowing what proportion of programmers use one > library or the other. I started using SQLite with PHP in version 5.2.x, when there wasn't SQLite3:: interface, so I chose to use PDO. Moreover, I don't want to lock myself into SQLite, PDO provides a somewhat more flexible approach. > As long as you set an acceptable timeout, which you do with one of these > calls depending which library you're using > > <http://php.net/manual/en/pdo.setattribute.php> > > <http://uk.php.net/manual/en/sqlite3.busytimeout.php> > > your web service probably isn't going to run into problems. ?What might be > worrying you right now is the result of the default timeout being zero, > something which is arguably weird. ?In other words, unless you specify a > timeout yourself any report of a lock is instantly treated like an error. > ?Set your timeout to one second or five seconds and the behaviour will be > more reasonable. I'd done some research into this since I asked my question and learned some things. According to http://bugs.php.net/bug.php?id=38182 and http://www.serverphorums.com/read.php?7,118071, PDO_SQLITE defaults to a 60 second busy timeout. This should be enough. > Second, most transactions and locks in SQLite from PHP are fleeting. > ?Generally you want your web page to list some records or do one update. ?You > wouldn't have a process keep a lock active for a long time because this would > correspond to your server taking a long time to show a web page, and nobody > wants that. ?So a lock by one process probably isn't going to last very long > -- probably a fraction of a second. ?Access for a web page is unlikely to > involve deadlock because of the nature of web pages: they generally don't > interact with the user while a transaction is open. One would think so :) But Drupal people have run into the opposite (http://drupal.org/node/1120020 and http://stackoverflow.com/questions/6108602/avoiding-locked-sqlite-database-timeouts-with-php-pdo). This seems to happen for them mostly when they are indexing their data a visitor to a site requests a page. Apparently, their indexing tasks is long running and write intensive. I think they should rework this tasks. ------------------------------ Message: 2 Date: Tue, 20 Dec 2011 11:27:23 -0600 From: romtek <rom...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] How about the way put a database of SQLite 3 beside web folder? Message-ID: <caaqe0hzpravubmgou2hxw6wqlkmporf7_m_cff0wubhkbop...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Fri, Dec 16, 2011 at 8:31 AM, Simon Slavin <slav...@bigfraud.org> wrote: > I would not advise putting it in a folder that you are serving to the web > since this would allow anyone browsing yourweb site to inspect the full > contents of the file. One could easily configure the server to *not* serve database files (or contents of folders) to a site's visitor. Therefore, it could be located anywhere. ------------------------------ Message: 3 Date: Tue, 20 Dec 2011 17:41:06 +0000 From: Simon Slavin <slav...@bigfraud.org> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] Strange behavior for timeouts in transactions Message-ID: <9f775da5-1d94-40ac-82b6-084b78355...@bigfraud.org> Content-Type: text/plain; charset=iso-8859-1 On 20 Dec 2011, at 5:21pm, romtek wrote: > I'd done some research into this since I asked my question and learned > some things. According to http://bugs.php.net/bug.php?id=38182 and > http://www.serverphorums.com/read.php?7,118071, PDO_SQLITE defaults to > a 60 second busy timeout. This should be enough. Agreed. Certainly an unexpected pause of more than 60 seconds. The default of 60 contradicts something I was told, but that might have been for a different version of PHP. >> Second, most transactions and locks in SQLite from PHP are fleeting. >> Generally you want your web page to list some records or do one update. You >> wouldn't have a process keep a lock active for a long time because this >> would correspond to your server taking a long time to show a web page, and >> nobody wants that. So a lock by one process probably isn't going to last >> very long -- probably a fraction of a second. Access for a web page is >> unlikely to involve deadlock because of the nature of web pages: they >> generally don't interact with the user while a transaction is open. > > > One would think so :) But Drupal people have run into the opposite > (http://drupal.org/node/1120020 and > http://stackoverflow.com/questions/6108602/avoiding-locked-sqlite-database-timeouts-with-php-pdo). > This seems to happen for them mostly when they are indexing their data > a visitor to a site requests a page. Apparently, their indexing tasks > is long running and write intensive. I think they should rework this > tasks. Not sure why someone would start a long-running blocking process for an application which purports to be running. When I do this I give the application a status so it just knows not to try accessing the data file until the blocking process is finished. Simon. ------------------------------ Message: 4 Date: Tue, 20 Dec 2011 14:34:35 -0500 From: "jim-on-linux" <inq1...@inqvista.com> To: sqlite-users@sqlite.org Subject: [sqlite] insert error Message-ID: <201112201434.35461.inq1...@inqvista.com> Content-Type: Text/Plain; charset=us-ascii Can someone let me know why the following keeps giving invalid syntax err msg. con = sqlite3.connect(sqldb) cursor = con.cursor() cursor.execute insert into default (rowname) values ( '1' ) ; con.commit() con.close() I get invalid syntax pointing to the t in insert. jimonlinux ------------------------------ Message: 5 Date: Tue, 20 Dec 2011 20:40:50 +0100 From: Petite Abeille <petite.abei...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] insert error Message-ID: <e45f90d1-322d-4945-b267-1d03de180...@gmail.com> Content-Type: text/plain; charset=us-ascii On Dec 20, 2011, at 8:34 PM, jim-on-linux wrote: > cursor.execute insert into default (rowname) values ( '1' ) ; 'default' is a keyword: http://www.sqlite.org/lang_keywords.html If you insist on that name, double quote it. ------------------------------ Message: 6 Date: Tue, 20 Dec 2011 19:46:48 +0000 (UTC) From: epank...@comcast.net To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] insert error Message-ID: <2049798296.1335563.1324410408760.javamail.r...@sz0122a.emeryville.ca.mail.comcast.net> Content-Type: text/plain; charset=utf-8 Besides that, shouldn't it be cursor.execute "insert into ""default"" (rowname) values('1');" I would expect that the execute command is expecting a string containing the SQL to execute. ----- Original Message ----- From: "Petite Abeille" <petite.abei...@gmail.com> To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> Sent: Tuesday, December 20, 2011 2:40:50 PM Subject: Re: [sqlite] insert error On Dec 20, 2011, at 8:34 PM, jim-on-linux wrote: > cursor.execute insert into default (rowname) values ( '1' ) ; 'default' is a keyword: http://www.sqlite.org/lang_keywords.html If you insist on that name, double quote it. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ------------------------------ Message: 7 Date: Tue, 20 Dec 2011 14:52:05 -0600 From: Nico Williams <n...@cryptonector.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] Procedure (Conditional statement) workaround Message-ID: <CAK3OfOjv1BEGNqUT0y2nd+JpU6HPuCMcXu21A=z+aq3hdw-...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Tue, Dec 20, 2011 at 5:21 AM, John Gillespie <rjkgilles...@gmail.com> wrote: > This would make a good entry for an Obfuscated SQL contest. > Well done Thanks, I guess :) It was a fun little SQL ditty to write, and only took a few minutes. (Now I do I a search and see that factorial in SQL is a fairly common toy problem, and here you can see a recursive query version of factorial: http://www.sqlservercentral.com/Forums/Topic164151-213-2.aspx (on page 2, today, search for "with fact"). It'd be nice to have recursive queries (with tail-call optimization). Then a lot of things get easier. Of course, recursive algorithms (and thus recursive queries) do tend to look obfuscated to some, but a combination of C/Python/... and SQL can also look obfuscated, so it's really a question of what you're trading off for what, and the best thing to do is to go for maintainability (i.e., readability), because someone will have to support whatever code you write. Taking advantage of SQL expressibility requires writing lengthy block comments for the benefit of the next person to read that code. Nico -- ------------------------------ Message: 8 Date: Tue, 20 Dec 2011 22:35:37 +0100 From: Petite Abeille <petite.abei...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] Procedure (Conditional statement) workaround Message-ID: <040cbf3e-8e6c-4a01-978e-2efea9dbc...@gmail.com> Content-Type: text/plain; charset=us-ascii On Dec 20, 2011, at 9:52 PM, Nico Williams wrote: > It'd be nice to have recursive queries (with tail-call optimization). Yes for recursive with clauses! http://gennick.com/with.html > Then a lot of things get easier. Like solving that damn sodoku puzzle: Solving a Sudoku using Recursive Subquery Factoring http://technology.amis.nl/blog/6404/oracle-rdbms-11gr2-solving-a-sudoku-using-recursive-subquery-factoring ------------------------------ Message: 9 Date: Tue, 20 Dec 2011 23:27:37 -0300 From: Esteban Cervetto <estebancs...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: [sqlite] run a script in Visual Basic.NET Message-ID: <calt7ijdgnexktxgzpyyyewao91n4ldm-rk9avq7fd3g-jy-...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 How can I run an SQL script written in a txt file in Visual Basic .NET I am using *System.Data.SQLite.dll* 1.0.66.0 library I want to avoid write the SQL code in the visual basic routine. Any Ideas? Regards Esteban ------------------------------ Message: 10 Date: Wed, 21 Dec 2011 03:31:33 +0000 From: Simon Slavin <slav...@bigfraud.org> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] run a script in Visual Basic.NET Message-ID: <cfa2a902-444c-4ddb-8288-4624d9214...@bigfraud.org> Content-Type: text/plain; charset=us-ascii On 21 Dec 2011, at 2:27am, Esteban Cervetto wrote: > How can I run an SQL script written in a txt file in Visual Basic .NET > > I am using *System.Data.SQLite.dll* 1.0.66.0 library > > I want to avoid write the SQL code in the visual basic routine. Either write some Visual BASIC code to read in the contents of the file and call _exec() on it, or issue an OS call to tell sqlite3.exe to execute the contents of that file. Simon. ------------------------------ Message: 11 Date: Tue, 20 Dec 2011 21:37:22 +0000 From: "Jacob A. Camp" <jacob.c...@mastercam.com> To: "'sqlite-users@sqlite.org'" <sqlite-users@sqlite.org> Subject: [sqlite] sqlite3_column_text() returning partial results Message-ID: <250c42f68e068a4e9713b45ba15cd6f335150...@uniblab.cncsoftware.com> Content-Type: text/plain; charset="us-ascii" Hello, I've been looking into an issue that a few of our programmers have looked at as well and it left us all wondering. Basically, our database has a VARCHAR column that has an XML file written to it when the object is manipulated. I can use a tool to view the database file and I can ensure that the entire field is filled out correctly and the XML is correctly formed. The field in the database contains 8955 characters and when I execute the sqlite3_column_text() on that specific column to access the data, the const unsigned char* that's returned only contains 2030 characters and the XML file that I'm trying to reconstruct from it then becomes unusable. I even attempted digging into the SQLite class and it seems that this value is obtained from the official function calls. In sqlite3.c: static Mem *columnMem(sqlite3_stmt *pStmt, int i){ Vdbe *pVm; int vals; Mem *pOut; pVm = (Vdbe *)pStmt; if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){ sqlite3_mutex_enter(pVm->db->mutex); vals = sqlite3_data_count(pStmt); pOut = &pVm->pResultSet[i]; After the last line has been executed pOut contains members z and zMalloc which both contain the same memory location that points to the char* that contains the first 2030 characters and none of the rest that are stored in the VARCHAR field. Is there some limit to the amount of data that can be returned by this function? I read over most of the documentation and didn't see it mentioning any sort of restriction. Thanks in advance, --Jake ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mastercam.com ********************************************************************** ------------------------------ Message: 12 Date: Wed, 21 Dec 2011 08:20:02 -0500 From: "Igor Tandetnik" <itandet...@mvps.org> To: sqlite-users@sqlite.org Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <jcsme5$7s2$1...@dough.gmane.org> Content-Type: text/plain; charset="iso-8859-1" Jacob A. Camp <jacob.c...@mastercam.com> wrote: > The field in the database contains 8955 characters and when I execute the > sqlite3_column_text() on that specific column to access > the data, the const unsigned char* that's returned only contains 2030 > characters What do you mean by that? sqlite3_column_text doesn't provide any length delimiter. What's in p[2030], p[2031] and so on (where p is a pointer obtained from sqlite3_column_text)? Are you examining the string immediately after calling sqlite3_column_text? Some sqlite3_* calls invalidate the pointer (by reusing or freeing the memory behind it). What does sqlite3_column_bytes return for this column? -- Igor Tandetnik ------------------------------ Message: 13 Date: Wed, 21 Dec 2011 05:31:52 -0800 (PST) From: nobre <rafael.ro...@novaprolink.com.br> To: sqlite-users@sqlite.org Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <33016758.p...@talk.nabble.com> Content-Type: text/plain; charset=us-ascii Is there any chance you are storing a \0 char inside the xml ? Jacob A. Camp wrote: > > Hello, > > I've been looking into an issue that a few of our programmers have looked > at as well and it left us all wondering. Basically, our database has a > VARCHAR column that has an XML file written to it when the object is > manipulated. I can use a tool to view the database file and I can ensure > that the entire field is filled out correctly and the XML is correctly > formed. > > The field in the database contains 8955 characters and when I execute the > sqlite3_column_text() on that specific column to access the data, the > const unsigned char* that's returned only contains 2030 characters and the > XML file that I'm trying to reconstruct from it then becomes unusable. I > even attempted digging into the SQLite class and it seems that this value > is obtained from the official function calls. > > In sqlite3.c: > > static Mem *columnMem(sqlite3_stmt *pStmt, int i){ > Vdbe *pVm; > int vals; > Mem *pOut; > > pVm = (Vdbe *)pStmt; > if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){ > sqlite3_mutex_enter(pVm->db->mutex); > vals = sqlite3_data_count(pStmt); > pOut = &pVm->pResultSet[i]; > > After the last line has been executed pOut contains members z and zMalloc > which both contain the same memory location that points to the char* that > contains the first 2030 characters and none of the rest that are stored in > the VARCHAR field. > > Is there some limit to the amount of data that can be returned by this > function? I read over most of the documentation and didn't see it > mentioning any sort of restriction. > > Thanks in advance, > --Jake > > ********************************************************************** > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > > This footnote also confirms that this email message has been swept by > MIMEsweeper for the presence of computer viruses. > > www.mastercam.com > ********************************************************************** > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/sqlite3_column_text%28%29-returning-partial-results-tp33016613p33016758.html Sent from the SQLite mailing list archive at Nabble.com. ------------------------------ Message: 14 Date: Wed, 21 Dec 2011 13:34:06 +0000 From: Simon Slavin <slav...@bigfraud.org> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <76f253e4-e241-4fe3-9971-b05b1a211...@bigfraud.org> Content-Type: text/plain; charset=us-ascii On 21 Dec 2011, at 1:31pm, nobre wrote: > Is there any chance you are storing a \0 char inside the xml ? Or that you are mixing 8-bit and 16-bit Unicode in such a way that one of your routines thinks that it has read a 0x00 termination character ? Simon. ------------------------------ Message: 15 Date: Wed, 21 Dec 2011 17:42:21 +0400 From: Alexey Pechnikov <pechni...@mobigroup.ru> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] Bug in trigger: when comparing a value of an int column to a quoted value Message-ID: <canmyfjkoeteum+j95tx9k06ycjauakb9ga2nfegqxhu3rtz...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 The problem can be fixed by variables bindings patch: http://sqlite.mobigroup.ru/wiki?name=tclsqlite I think, you can do same for you lang. -- Best regards, Alexey Pechnikov. http://pechnikov.tel/ ------------------------------ Message: 16 Date: Wed, 21 Dec 2011 15:04:33 +0000 (UTC) From: Jake <jacob.c...@mastercam.com> To: sqlite-users@sqlite.org Subject: [sqlite] sqlite3_column_text() returning partial results Message-ID: <loom.20111221t155453-...@post.gmane.org> Content-Type: text/plain; charset=us-ascii Simon Slavin <slavins@...> writes: > > > On 21 Dec 2011, at 1:31pm, nobre wrote: > > > Is there any chance you are storing a \0 char inside the xml ? > > Or that you are mixing 8-bit and 16-bit Unicode in such a way that one of > your routines thinks that it has read a > 0x00 termination character ? > > Simon. > >From what I looked at so far, by taking the text and putting it into a basic text editor so I could see any special characters that would have been added. I didn't see any \0 or other odd things. I would check the mixing 8-bit and 16-bit Unicode but I need to research how to even figure something like that out. For the previous post asking what occurs after 2030, there's nothing because the returned value is only allocated for those characters. And regarding the recycling of the memory the actual return result of the function call after its complete is the same as when i'm viewing it while debugging. I can post the stored value and the value the call to sqlite3_column_text returns if that would be helpful (its just long so I wont post it). Jake ------------------------------ Message: 17 Date: Wed, 21 Dec 2011 10:28:23 -0500 From: "Igor Tandetnik" <itandet...@mvps.org> To: sqlite-users@sqlite.org Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <jcstuu$ur2$1...@dough.gmane.org> Content-Type: text/plain; charset="iso-8859-1" Jake <jacob.c...@mastercam.com> wrote: > For the previous post asking what occurs after 2030, there's nothing What do you mean, nothing? What exactly happens when you try to access p[2030]? > because the > returned value is only allocated for those characters. What makes you believe this? -- Igor Tandetnik ------------------------------ Message: 18 Date: Wed, 21 Dec 2011 15:41:16 +0000 From: "Jacob A. Camp" <jacob.c...@mastercam.com> To: "'General Discussion of SQLite Database'" <sqlite-users@sqlite.org> Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <250c42f68e068a4e9713b45ba15cd6f335151...@uniblab.cncsoftware.com> Content-Type: text/plain; charset="us-ascii" I have a line of code that executes that line: const unsigned char * temp2 = sqlite3_column_text(state, 0); This queries the database and after the call is complete I pass this value to another function. This function then fails because temp2 points to a location that contains the incomplete text. I then can view this text using my debugger and I can see that the value has been clipped and the XML is invalid. Trying to access memory locations outside whatever is allocated by the return of sqlite3_column_text sounds like it would result in undefined behavior? sqlite3_column_bytes returns 8960 if that's helpful. -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik Sent: Wednesday, December 21, 2011 10:29 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] sqlite3_column_text() returning partial results Jake <jacob.c...@mastercam.com> wrote: > For the previous post asking what occurs after 2030, there's nothing What do you mean, nothing? What exactly happens when you try to access p[2030]? > because the > returned value is only allocated for those characters. What makes you believe this? -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mastercam.com ********************************************************************** ------------------------------ Message: 19 Date: Wed, 21 Dec 2011 16:00:12 +0000 From: "Black, Michael (IS)" <michael.bla...@ngc.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <2C834176-8407-4FDA-B860-48D4229383F1@mimectl> Content-Type: text/plain; charset="iso-8859-1" What does strlen() tell you on the XML before you put it in the table? Can you boil all this down to one record in a table, and some code so we can all see what's going on? Do a .dump of the table and post the code. See if you can reproduce it in a simple example. Michael D. Black Senior Scientist Advanced Analytics Directorate Advanced GEOINT Solutions Operating Unit Northrop Grumman Information Systems ________________________________ From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Jacob A. Camp [jacob.c...@mastercam.com] Sent: Wednesday, December 21, 2011 9:41 AM To: 'General Discussion of SQLite Database' Subject: EXT :Re: [sqlite] sqlite3_column_text() returning partial results I have a line of code that executes that line: const unsigned char * temp2 = sqlite3_column_text(state, 0); This queries the database and after the call is complete I pass this value to another function. This function then fails because temp2 points to a location that contains the incomplete text. I then can view this text using my debugger and I can see that the value has been clipped and the XML is invalid. Trying to access memory locations outside whatever is allocated by the return of sqlite3_column_text sounds like it would result in undefined behavior? sqlite3_column_bytes returns 8960 if that's helpful. -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik Sent: Wednesday, December 21, 2011 10:29 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] sqlite3_column_text() returning partial results Jake <jacob.c...@mastercam.com> wrote: > For the previous post asking what occurs after 2030, there's nothing What do you mean, nothing? What exactly happens when you try to access p[2030]? > because the > returned value is only allocated for those characters. What makes you believe this? -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mastercam.com<http://www.mastercam.com/> ********************************************************************** _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ------------------------------ Message: 20 Date: Wed, 21 Dec 2011 11:19:22 -0500 From: Pavel Ivanov <paiva...@gmail.com> To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] sqlite3_column_text() returning partial results Message-ID: <CAG1a4rs-Uv7G2WYZbUJ5e_k4MfABMDviLPdPCWPGktVXy5=z...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Wed, Dec 21, 2011 at 10:41 AM, Jacob A. Camp <jacob.c...@mastercam.com> wrote: > I have a line of code that executes that line: > > const unsigned char * temp2 = sqlite3_column_text(state, 0); > > This queries the database and after the call is complete I pass this value to > another function. This function then fails because temp2 points to a location > that contains the incomplete text. I then can view this text using my > debugger and I can see that the value has been clipped and the XML is invalid. Let me ask Igor's questions once again. How does your function understand that text is incomplete? Your debugger can show you incomplete string because temp2 is not a zero-terminated string, it can contain zeros in the middle. > Trying to access memory locations outside whatever is allocated by the return > of sqlite3_column_text sounds like it would result in undefined behavior? How do you know how much memory sqlite3_column_text allocated for the return? > sqlite3_column_bytes returns 8960 if that's helpful. Hint: the above number means that sqlite3_column_text allocated exactly 8960 bytes for the text it returned. So whatever you use to define that returned text is incomplete gives you incorrect information. Pavel ------------------------------ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users End of sqlite-users Digest, Vol 48, Issue 21 ******************************************** _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users