Re: [sqlite] loading extension csv.c

2020-02-07 Thread chiahui chen
STAT_VTAB  -g -O2 -MT sqlite3-shell.o -MD -MP -MF
.deps/sqlite3-shell.Tpo -c -o sqlite3-shell.o `test -f 'shell.c' || echo
'./'`shell.c

mv -f .deps/sqlite3-shell.Tpo .deps/sqlite3-shell.Po

gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\"
-DPACKAGE_VERSION=\"3.31.1\" -DPACKAGE_STRING=\"sqlite\ 3.31.1\"
-DPACKAGE_BUGREPORT=\"http://www.sqlite.org\; -DPACKAGE_URL=\"\"
-DPACKAGE=\"sqlite\" -DVERSION=\"3.31.1\" -DSTDC_HEADERS=1
-DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\"
-DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1
-DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_EDITLINE_READLINE_H=1
-DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE=1 -DHAVE_ZLIB_H=1 -I.
-D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
-DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB
-DSQLITE_ENABLE_DBSTAT_VTAB  -g -O2 -MT sqlite3-sqlite3.o -MD -MP -MF
.deps/sqlite3-sqlite3.Tpo -c -o sqlite3-sqlite3.o `test -f 'sqlite3.c' ||
echo './'`sqlite3.c

mv -f .deps/sqlite3-sqlite3.Tpo .deps/sqlite3-sqlite3.Po

/bin/sh ./libtool  --tag=CC   --mode=link gcc -D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
-DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB
-DSQLITE_ENABLE_DBSTAT_VTAB  -g -O2   -o sqlite3 sqlite3-shell.o
sqlite3-sqlite3.o -lreadline -ltermcap  -lz

libtool: link: gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1
-DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1
-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY -DSQLITE_HAVE_ZLIB
-DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_DBPAGE_VTAB
-DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBSTAT_VTAB -g -O2 -o sqlite3
sqlite3-shell.o sqlite3-sqlite3.o  -lreadline -ltermcap -lz


Is there any suggestion? Just in case if my Mac operating system provides
some info (macOS High Sierra version 10.13.6)


Thank you in advance.


Appreciated,

Osman

On Thu, Feb 6, 2020 at 12:38 PM Richard Hipp  wrote:

> On 2/6/20, chiahui chen  wrote:
> > Hi,
> >
> > After few attempts to load csv extension, (already tried
> >
> > gcc -arch x86_64 -g -fPIC -dynamiclib csv.c -o csv.dylib
> >
> > and
> >
> > gcc  -g -fPIC -dynamiclib csv.c -o csv.dylib
> > )
> > Mac terminal returns errors as followings:
>
> I don't know what is causing your errors.  But I can show you what
> works for me, on a Mac:
>
> (1) Unpack the SQLite source-code tarball for version 3.31.1
>
> (2) Run:  ./configure && make
>
> (3) Run:  gcc -g -I. -fPIC -dynamiclib ext/misc/csv.c -o csv.dylib
>
> (4) Run: ./sqlite3
>
> (5) Within the SQLite command-line shell, do:  .load ./csv
>
> I suspect that the -I. is the option that you need, so that the build
> will pick up a proper sqlite3ext.h file, and not whatever sqlite3ext.h
> file that Apple has installed.  But that is just my guess.
>
> --
> D. Richard Hipp
> d...@sqlite.org
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] loading extension csv.c

2020-02-06 Thread chiahui chen
Hi,

After few attempts to load csv extension, (already tried

gcc -arch x86_64 -g -fPIC -dynamiclib csv.c -o csv.dylib

and

gcc  -g -fPIC -dynamiclib csv.c -o csv.dylib
)
Mac terminal returns errors as followings:

csv.c:115:3: error: no member named '__builtin___vsnprintf_chk' in 'struct
sqlite3_api_routines'

  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);

  ^

/usr/include/sqlite3ext.h:437:53: note: expanded from macro
'sqlite3_vsnprintf'

#define sqlite3_vsnprintf  sqlite3_api->vsnprintf

   ~~~  ^

/usr/include/secure/_stdio.h:75:3: note: expanded from macro 'vsnprintf'

  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)

  ^

csv.c:115:21: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'const void *' [-Wint-conversion]

  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);

^

csv.c:67:19: note: expanded from macro 'CSV_MXERR'

#define CSV_MXERR 200

  ^~~

/usr/include/secure/_stdio.h:75:57: note: expanded from macro 'vsnprintf'

  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)

^~~

/usr/include/secure/_common.h:39:54: note: expanded from macro
'__darwin_obsz'

#define __darwin_obsz(object) __builtin_object_size (object,
_USE_FORTIFY_LEVEL > 1 ? 1 : 0)

 ^~

csv.c:568:5: error: use of undeclared identifier 'sqlite3_str'

sqlite3_str *pStr = sqlite3_str_new(0);

^

csv.c:568:18: error: use of undeclared identifier 'pStr'

sqlite3_str *pStr = sqlite3_str_new(0);

 ^

csv.c:568:25: warning: implicit declaration of function 'sqlite3_str_new'
is invalid in C99 [-Wimplicit-function-declaration]

sqlite3_str *pStr = sqlite3_str_new(0);

^

csv.c:571:5: warning: implicit declaration of function
'sqlite3_str_appendf' is invalid in C99 [-Wimplicit-function-declaration]

sqlite3_str_appendf(pStr, "CREATE TABLE x(");

^

csv.c:571:25: error: use of undeclared identifier 'pStr'

sqlite3_str_appendf(pStr, "CREATE TABLE x(");

^

csv.c:581:29: error: use of undeclared identifier 'pStr'

sqlite3_str_appendf(pStr, "%sc%d TEXT", zSep, iCol);

^

csv.c:588:31: error: use of undeclared identifier 'pStr'

  sqlite3_str_appendf(pStr,"%s\"%w\" TEXT", zSep, z);

  ^

csv.c:597:31: error: use of undeclared identifier 'pStr'

  sqlite3_str_appendf(pStr,"%sc%d TEXT", zSep, ++iCol);

  ^

csv.c:603:25: error: use of undeclared identifier 'pStr'

sqlite3_str_appendf(pStr, ")");

^

csv.c:604:18: warning: implicit declaration of function
'sqlite3_str_finish' is invalid in C99 [-Wimplicit-function-declaration]

CSV_SCHEMA = sqlite3_str_finish(pStr);

 ^

csv.c:604:37: error: use of undeclared identifier 'pStr'

CSV_SCHEMA = sqlite3_str_finish(pStr);

^

csv.c:643:27: error: use of undeclared identifier 'SQLITE_VTAB_DIRECTONLY'

  sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);

  ^

4 warnings and 10 errors generated.

Can someone kindly explain why?
Is there any other step /modification required or even change needed to be
made, prior to compiling or loading an extension in general?

In case there is something I missed while compiling sqlite, here is how I
initially compiled it:

cc -DSQLITE_SOUNDEX -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -o sqlite3
shell.c sqlite3.c

Thank you in advance.

Osman
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] importing data to a table that has generated-columns

2020-01-26 Thread chiahui chen
Hi,

After creating a table (total 8 columns including 1 generated column) , I
tried to import data from a csv file (each record has values for 7 columns
that match the non-generated column names and data types, no headers ).

The system issued " error:  table has 7 columns but 8 values were supplied.
' I wonder why.

After experimenting different ways to import data to a table that has a
generated column, so far I only found that  .read command with a .sql file
that was output  as a result of  'mode insert'  is successful. Is there any
other ways to import data to an existing generated-column table?

Thank you advance.

Chiahui
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users