SQLite Forum

Timeline
Login

9 forum posts by user alaskanarcher

2021-12-27
05:20 Reply: gcc 11 compiler warning in sqlite3Fts5IndexQuery (artifact: ee55827a2d user: alaskanarcher)

I'm getting the same warning building the Go package crawshaw.io/sqlite.

$ go build crawshaw.io/sqlite
# crawshaw.io/sqlite
In file included from ./static.go:19:
././c/sqlite3.c: In function ‘sqlite3Fts5IndexQuery’:
././c/sqlite3.c:226544:18: warning: ‘memcpy’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
226544 |     if( nToken ) memcpy(&buf.p[1], pToken, nToken);
       |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2020-06-27
21:17 Reply: SQLITE_HAS_CODE is gone? (artifact: 1b9e6264ed user: alaskanarcher)

Just chiming in to voice my disappointment about the removal SQLITE_HAS_CODEC encryption API. SQLeet also relies on this.

DRH you are amazing and I appreciate all of the amazing work you have done and made available to the world for free. So I have nothing but gratitude for that. The loss of this interface is an unfortunate inconvenience to SQLeet and SQLCipher and their users though. I hope they are able to create workarounds soon.

2020-05-25
19:37 Reply: warning: function may return address of local variable -Wreturn-local-addr (artifact: 38e11d3113 user: alaskanarcher)

BTW I tried your patch and it does silence the warning. Thank you.

19:29 Reply: warning: function may return address of local variable -Wreturn-local-addr (artifact: fc7ae2ccff user: alaskanarcher)

Thanks for your thoughtful response.

I don't fully understand why the standin is necessary but I absolutely trust your expertise. The warning can be tolerated. It doesn't stop or hurt the build. It just will confuse Golang users of the package.

I think I will just apply your patch in the amalgamation that the Golang package builds, since if size and speed is the ultimate priority for a user, Golang is probably the wrong language choice anyway.

19:21 Reply: warning: function may return address of local variable -Wreturn-local-addr (artifact: 1b3f9adfd8 user: alaskanarcher)
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/aslevy/.cache/go-build"
GOENV="/home/aslevy/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/aslevy/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/aslevy/repos/go/AdamSLevy/flagbind/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build049582596=/tmp/go-build -gno-record-gcc-switches"

Please also note that if you are building the master branch of crawshaw.io/sqlite I pushed a small patch to silence the warning, but from Richard Hipp's response I think that my patch may be foolish. If you want to reproduce it try commit 1afc5f0 on the repo at https://github.com/crawshaw/sqlite/

00:29 Post: warning: function may return address of local variable -Wreturn-local-addr (artifact: 845dd0be91 user: alaskanarcher)

I am getting the following warning when compiling the last two official release amalgamations using CGo:

$ go build
# crawshaw.io/sqlite
In file included from ./static.go:19:
././c/sqlite3.c: In function 'sqlite3SelectNew':
././c/sqlite3.c:128048:10: warning: function may return address of local variable [-Wreturn-local-addr]
128048 |   return pNew;
       |          ^~~~
././c/sqlite3.c:128008:10: note: declared here
128008 |   Select standin;
       |          ^~~~~~~

The relevant amalgamation code is below.

Clearly the standin variable is protected from being exposed using the assert at the bottom. But perhaps this should be made into a global to avoid the warning.

/*
** Allocate a new Select structure and return a pointer to that
** structure.
*/
SQLITE_PRIVATE Select *sqlite3SelectNew(
  Parse *pParse,        /* Parsing context */
  ExprList *pEList,     /* which columns to include in the result */
  SrcList *pSrc,        /* the FROM clause -- which tables to scan */
  Expr *pWhere,         /* the WHERE clause */
  ExprList *pGroupBy,   /* the GROUP BY clause */
  Expr *pHaving,        /* the HAVING clause */
  ExprList *pOrderBy,   /* the ORDER BY clause */
  u32 selFlags,         /* Flag parameters, such as SF_Distinct */
  Expr *pLimit          /* LIMIT value.  NULL means not used */
){
  Select *pNew;
  Select standin;
  pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) );
  if( pNew==0 ){
    assert( pParse->db->mallocFailed );
    pNew = &standin;
  }
  if( pEList==0 ){
    pEList = sqlite3ExprListAppend(pParse, 0,
                                   sqlite3Expr(pParse->db,TK_ASTERISK,0));
  }
  pNew->pEList = pEList;
  pNew->op = TK_SELECT;
  pNew->selFlags = selFlags;
  pNew->iLimit = 0;
  pNew->iOffset = 0;
  pNew->selId = ++pParse->nSelect;
  pNew->addrOpenEphm[0] = -1;
  pNew->addrOpenEphm[1] = -1;
  pNew->nSelectRow = 0;
  if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));
  pNew->pSrc = pSrc;
  pNew->pWhere = pWhere;
  pNew->pGroupBy = pGroupBy;
  pNew->pHaving = pHaving;
  pNew->pOrderBy = pOrderBy;
  pNew->pPrior = 0;
  pNew->pNext = 0;
  pNew->pLimit = pLimit;
  pNew->pWith = 0;
#ifndef SQLITE_OMIT_WINDOWFUNC
  pNew->pWin = 0;
  pNew->pWinDefn = 0;
#endif
  if( pParse->db->mallocFailed ) {
    clearSelect(pParse->db, pNew, pNew!=&standin);
    pNew = 0;
  }else{
    assert( pNew->pSrc!=0 || pParse->nErr>0 );
  }
  assert( pNew!=&standin );
  return pNew;
}
2020-05-15
21:52 Reply: Feature Request: more flexible timestring parsing (artifact: 2ee4bb6c4b user: alaskanarcher)

Is this something that can readily be done from within the CLI interface?

2020-05-09
22:04 Reply: Feature Request: more flexible timestring parsing (artifact: 533dba66cf user: alaskanarcher)

I believe it does. But I'm more knowledgeable about calling C code from Go than building Go code to be linked for another lib.

The Go package could be very simple.

package timeparse

import "time"

func Parse(layout, value string) (string, error) {
        t, err := time.Parse(layout, value)
        if err != nil {
                return "", err
        }
        return t.Unix().Format(`2006-01-02T15:04:05.999999999Z`), nil
}
03:22 Post: Feature Request: more flexible timestring parsing (artifact: 8166048208 user: alaskanarcher)

Time strings come in a wide range of formats many of which do not conform to ISO-8601.

I propose an additional time parsing function or modifier that allows for more flexible parsing of time strings. I suggest modeling it from Golang's time.Parse function. This allows a user to write a specific time stamp in the desired format:

  Mon Jan 2 15:04:05 -0700 MST 2006

The implementation and docs for this method of parsing can be found here:

https://pkg.go.dev/time?tab=doc#Parse

Thoughts?