- update to sqlite-3.5.9

- merge espie's patches
- fix apps such as p5-DBD-SQLite, by adding weak pthread functions.
also include some bug fixes from kurt@.  the work has been done by
kurt@, and espie@.  thanks!
ok kurt@, espie@, bernd@
This commit is contained in:
martynas 2008-07-23 17:31:17 +00:00
parent 23611ce32b
commit d55bea2e4b
12 changed files with 362 additions and 27 deletions

View File

@ -1,14 +1,14 @@
# $OpenBSD: Makefile,v 1.32 2007/09/15 18:51:35 steven Exp $
# $OpenBSD: Makefile,v 1.33 2008/07/23 17:31:17 martynas Exp $
COMMENT-main= embedded SQL implementation
COMMENT-tcl= TCL bindings for Sqlite3
V= 3.4.2
V= 3.5.9
DISTNAME= sqlite-${V}
PKGNAME-main= sqlite3-${V}
PKGNAME-tcl= sqlite3-tcl-${V}
CATEGORIES= databases
SHARED_LIBS += sqlite3 9.0 # .8.6
SHARED_LIBS += tclsqlite3 9.0 # .8.6
SHARED_LIBS += sqlite3 10.0 # .8.6
SHARED_LIBS += tclsqlite3 10.0 # .8.6
MASTER_SITES= ${HOMEPAGE}
@ -20,12 +20,13 @@ PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
WANTLIB-main= c ncurses readline
WANTLIB-main= c ncurses pthread readline
USE_LIBTOOL= Yes
CONFIGURE_STYLE=gnu
CONFIGURE_ARGS+=${CONFIGURE_SHARED}
CONFIGURE_ARGS+=${CONFIGURE_SHARED} \
--enable-threads-override-locks
# XXX gcc bug? some regress tests crash w/-O2 but not -Os
.if ${MACHINE_ARCH} == "amd64"
@ -44,8 +45,7 @@ MULTI_PACKAGES=-main
MULTI_PACKAGES+=-tcl
.endif
LIB_DEPENDS-tcl=sqlite3.>=9.0::databases/sqlite3 \
tcl84.>=1.0:tcl-8.4.*:lang/tcl/8.4
BUILD_DEPENDS-tcl= tcl84.>=1.0:tcl-8.4.*:lang/tcl/8.4
.if ${MULTI_PACKAGES:M-tcl}
CONFIGURE_ARGS+=--with-tcl=${LOCALBASE}/lib/tcl8.4
@ -65,4 +65,10 @@ CONFIGURE_ARGS+=--disable-tcl
NO_REGRESS= Yes
.endif
# Don't include dependency on pthreads, weak pthread functions are
# used for non-threaded applications.
post-install:
perl -pi -e s,'\-pthread','',g ${PREFIX}/lib/libsqlite3.la \
${PREFIX}/lib/pkgconfig/sqlite3.pc
.include <bsd.port.mk>

View File

@ -1,5 +1,5 @@
MD5 (sqlite-3.4.2.tar.gz) = L+7JtCn5KYyfKIQgyLRJ+A==
RMD160 (sqlite-3.4.2.tar.gz) = WDNSP+3O1EsYzClVtjVr4AcTQSs=
SHA1 (sqlite-3.4.2.tar.gz) = GrKCcZx8JwhTY0HbWyDzmrJ6ZU0=
SHA256 (sqlite-3.4.2.tar.gz) = CthsSybNaHEisVi/hI8KB9fNZEAz0VxPQ7bWQ710zYE=
SIZE (sqlite-3.4.2.tar.gz) = 2377646
MD5 (sqlite-3.5.9.tar.gz) = tYQSkEtC/knlooHpnaD9cg==
RMD160 (sqlite-3.5.9.tar.gz) = 3armhmQZZoAhA3pJfDY+YZTefeU=
SHA1 (sqlite-3.5.9.tar.gz) = jYH7T/YGCVc05yHjzwC8nThZoFU=
SHA256 (sqlite-3.5.9.tar.gz) = fdMxkWsTR5aVgum84Z+87tiXLoB+ME4Oc3BH64D8YRw=
SIZE (sqlite-3.5.9.tar.gz) = 2201083

View File

@ -1,12 +1,64 @@
$OpenBSD: patch-Makefile_in,v 1.7 2007/06/26 19:13:37 espie Exp $
--- Makefile.in.orig Thu Jun 14 22:54:38 2007
+++ Makefile.in Tue Jun 26 20:39:45 2007
@@ -711,6 +711,8 @@ clean:
distclean: clean
rm -f config.log config.status libtool Makefile config.h
$OpenBSD: patch-Makefile_in,v 1.8 2008/07/23 17:31:17 martynas Exp $
--- Makefile.in.orig Mon May 12 19:10:26 2008
+++ Makefile.in Sun Jul 20 21:18:43 2008
@@ -96,7 +96,7 @@ TEXE = @TARGET_EXEEXT@
#
HAVE_TCL = @HAVE_TCL@
+.PHONY: test
-# This is the command to use for tclsh - normally just "tclsh", but we may
+# This is the command to use for tclsh8.4 - normally just "tclsh8.4", but we may
# know the specific version we want to use
#
TCLSH_CMD = @TCLSH_CMD@
@@ -160,11 +160,11 @@ OBJS0 = alter.lo analyze.lo attach.lo auth.lo bitvec.l
select.lo table.lo tokenize.lo trigger.lo update.lo \
util.lo vacuum.lo \
vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbefifo.lo vdbemem.lo \
- where.lo utf.lo legacy.lo vtab.lo
+ where.lo utf.lo legacy.lo vtab.lo pthread_stub.lo
# Object files for the amalgamation.
#
-OBJS1 = sqlite3.lo
+OBJS1 = sqlite3.lo pthread_stub.lo
# Determine the real value of LIBOBJ based on the 'configure' script
#
@@ -246,7 +246,8 @@ SRC = \
$(TOP)/src/vdbemem.c \
$(TOP)/src/vdbeInt.h \
$(TOP)/src/vtab.c \
- $(TOP)/src/where.c
+ $(TOP)/src/where.c \
+ $(TOP)/src/pthread_stub.c
# Generated source code files
#
@@ -392,7 +393,7 @@ HDR += \
# hidden when the library is built via the amalgamation).
#
TESTFIXTURE_SRC0 = $(TESTSRC2) libsqlite3.la
-TESTFIXTURE_SRC1 = sqlite3.c
+TESTFIXTURE_SRC1 = sqlite3.c $(TOP)/src/pthread_stub.c
TESTFIXTURE_SRC = $(TESTSRC) $(TOP)/src/tclsqlite.c $(TESTFIXTURE_SRC$(USE_AMALGAMATION))
@@ -454,6 +455,9 @@ lemon$(BEXE): $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
sqlite3.lo: sqlite3.c
$(LTCOMPILE) -c sqlite3.c
+pthread_stub.lo: $(TOP)/src/pthread_stub.c
+ $(LTCOMPILE) -c $(TOP)/src/pthread_stub.c
+
# Rules to build individual files
#
alter.lo: $(TOP)/src/alter.c $(HDR)
@@ -720,6 +724,8 @@ clean:
distclean: clean
rm -f config.log config.status libtool Makefile sqlite3.pc
+
+.PHONY: test
#
# Windows section
#

View File

@ -1,7 +1,16 @@
$OpenBSD: patch-configure,v 1.2 2007/04/14 19:34:03 steven Exp $
--- configure.orig Thu Mar 29 20:39:30 2007
+++ configure Sat Apr 7 08:04:17 2007
@@ -19338,7 +19338,7 @@ echo "${ECHO_T}file not found" >&6; }
$OpenBSD: patch-configure,v 1.3 2008/07/23 17:31:17 martynas Exp $
--- configure.orig Mon May 12 20:57:21 2008
+++ configure Mon Jul 21 11:26:29 2008
@@ -11088,7 +11088,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_search_pthread_create="-l$ac_lib"
+ ac_cv_search_pthread_create="-$ac_lib"
break
else
echo "$as_me: failed program was:" >&5
@@ -11433,7 +11433,7 @@ echo "${ECHO_T}file not found" >&6
eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-publish_sh,v 1.1 2008/07/23 17:31:17 martynas Exp $
--- publish.sh.orig Mon Jul 21 11:24:47 2008
+++ publish.sh Mon Jul 21 11:25:05 2008
@@ -53,13 +53,13 @@ TCLDIR=/home/drh/tcltk/846/linux/846linux
TCLSTUBLIB=$TCLDIR/libtclstub8.4g.a
CFLAGS="-Os -DSQLITE_ENABLE_FTS3=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1"
echo '***** BUILDING shared libraries for linux'
-gcc $CFLAGS -shared tclsqlite3.c $TCLSTUBLIB -o tclsqlite3.so -lpthread
+gcc $CFLAGS -shared tclsqlite3.c $TCLSTUBLIB -o tclsqlite3.so -pthread
strip tclsqlite3.so
chmod 644 tclsqlite3.so
mv tclsqlite3.so tclsqlite-$VERS.so
gzip tclsqlite-$VERS.so
mv tclsqlite-$VERS.so.gz doc
-gcc $CFLAGS -shared sqlite3.c -o sqlite3.so -lpthread
+gcc $CFLAGS -shared sqlite3.c -o sqlite3.so -pthread
strip sqlite3.so
chmod 644 sqlite3.so
mv sqlite3.so sqlite-$VERS.so

View File

@ -0,0 +1,85 @@
$OpenBSD: patch-src_os_unix_c,v 1.3 2008/07/23 17:31:17 martynas Exp $
--- src/os_unix.c.orig Tue May 13 08:51:29 2008
+++ src/os_unix.c Wed Jul 23 10:46:40 2008
@@ -61,6 +61,9 @@
#if SQLITE_THREADSAFE
# include <pthread.h>
# define SQLITE_UNIX_THREADS 1
+# if SQLITE_THREAD_OVERRIDE_LOCK != 1 || defined(SQLITE_TEST)
+# define SQLITE_NEED_TID_CHECKS 1
+# endif
#endif
/*
@@ -97,7 +100,7 @@ struct unixFile {
int h; /* The file descriptor */
unsigned char locktype; /* The type of lock held on this fd */
int dirfd; /* File descriptor for the directory */
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
pthread_t tid; /* The thread that "owns" this unixFile */
#endif
};
@@ -138,7 +141,7 @@ struct unixFile {
** The threadid macro resolves to the thread-id or to 0. Used for
** testing and debugging only.
*/
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
#define threadid pthread_self()
#else
#define threadid 0
@@ -160,7 +163,7 @@ struct unixFile {
** recomputed because its key includes the thread-id. See the
** transferOwnership() function below for additional information
*/
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
# define SET_THREADID(X) (X)->tid = pthread_self()
# define CHECK_THREADID(X) (threadsOverrideEachOthersLocks==0 && \
!pthread_equal((X)->tid, pthread_self()))
@@ -281,7 +284,7 @@ struct unixFile {
struct lockKey {
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
pthread_t tid; /* Thread ID or zero if threads can override each other */
#endif
};
@@ -371,7 +374,7 @@ static void leaveMutex(){
sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
}
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
/*
** This variable records whether or not threads can override each others
** locks.
@@ -508,7 +511,7 @@ static void testThreadLockingBehavior(int fd_orig){
close(fd);
threadsOverrideEachOthersLocks = d[0].result==0 && d[1].result==0;
}
-#endif /* SQLITE_THREADSAFE */
+#endif /* SQLITE_NEED_TID_CHECKS */
/*
** Release a lockInfo structure previously allocated by findLockInfo().
@@ -641,7 +644,7 @@ static int findLockInfo(
memset(&key1, 0, sizeof(key1));
key1.dev = statbuf.st_dev;
key1.ino = statbuf.st_ino;
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
if( threadsOverrideEachOthersLocks<0 ){
testThreadLockingBehavior(fd);
}
@@ -737,7 +740,7 @@ static const char *locktypeName(int locktype){
** If the unixFile is locked and an ownership is wrong, then return
** SQLITE_MISUSE. SQLITE_OK is returned if everything works.
*/
-#if SQLITE_THREADSAFE
+#if SQLITE_NEED_TID_CHECKS
static int transferOwnership(unixFile *pFile){
int rc;
pthread_t hSelf;

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-src_pthread_stub_c,v 1.1 2008/07/23 17:31:17 martynas Exp $
--- src/pthread_stub.c.orig Wed Jul 23 10:44:20 2008
+++ src/pthread_stub.c Wed Jul 23 10:47:11 2008
@@ -0,0 +1,28 @@
+/* stubs for pthreads function, quick and dirty */
+#if SQLITE_THREADSAFE && !defined(SQLITE_TEST) && SQLITE_THREAD_OVERRIDE_LOCK == 1
+
+#include <pthread.h>
+
+#define WEAKALIAS(f,g ) extern f __attribute__((__weak__, __alias__(#g)))
+
+static pthread_t _sqlite_self_stub()
+{
+ return 0;
+}
+
+static int _sqlite_zero_stub()
+{
+ return 0;
+}
+
+WEAKALIAS(pthread_t pthread_self(void), _sqlite_self_stub);
+WEAKALIAS(int pthread_mutex_init(pthread_mutex_t *a, const pthread_mutexattr_t *b), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutex_destroy(pthread_mutex_t *a), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutex_lock(pthread_mutex_t *a), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutex_trylock(pthread_mutex_t *a), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutex_unlock(pthread_mutex_t *a), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutexattr_init(pthread_mutexattr_t *a), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutexattr_settype(pthread_mutexattr_t *a, int b), _sqlite_zero_stub);
+WEAKALIAS(int pthread_mutexattr_destroy(pthread_mutexattr_t *a), _sqlite_zero_stub);
+
+#endif

View File

@ -0,0 +1,58 @@
$OpenBSD: patch-src_sqliteInt_h,v 1.1 2008/07/23 17:31:17 martynas Exp $
--- src/sqliteInt.h.orig Tue May 13 16:27:34 2008
+++ src/sqliteInt.h Sat Jul 19 15:10:45 2008
@@ -35,9 +35,6 @@
#pragma warn -spa /* Suspicous pointer arithmetic */
#endif
-/* Needed for various definitions... */
-#define _GNU_SOURCE
-
/*
** Include standard header files as necessary
*/
@@ -327,32 +324,26 @@ typedef INT16_TYPE i16; /* 2-byte signed in
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
typedef UINT8_TYPE i8; /* 1-byte signed integer */
-/*
-** Macros to determine whether the machine is big or little endian,
-** evaluated at runtime.
-*/
-#ifdef SQLITE_AMALGAMATION
-const int sqlite3one;
+#include <sys/endian.h>
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define SQLITE_BIGENDIAN 1
+#define SQLITE_LITTLEENDIAN 0
+#define SQLITE_UTF16NATIVE SQLITE_UTF16BE
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define SQLITE_BIGENDIAN 0
+#define SQLITE_LITTLEENDIAN 1
+#define SQLITE_UTF16NATIVE SQLITE_UTF16LE
#else
-extern const int sqlite3one;
+#error "Help, I'm trapped in a PDP11"
#endif
-#if defined(i386) || defined(__i386__) || defined(_M_IX86)
-# define SQLITE_BIGENDIAN 0
-# define SQLITE_LITTLEENDIAN 1
-# define SQLITE_UTF16NATIVE SQLITE_UTF16LE
-#else
-# define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)
-# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
-# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
-#endif
/*
** Constants for the largest and smallest possible 64-bit signed integers.
** These macros are designed to work correctly on both 32-bit and 64-bit
** compilers.
*/
-#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
-#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
+#define LARGEST_INT64 INT64_MAX
+#define SMALLEST_INT64 INT64_MIN
/*
** An instance of the following structure is used to store the busy-handler

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-src_sqlite_h_in,v 1.1 2008/07/23 17:31:17 martynas Exp $
--- src/sqlite.h.in.orig Mon May 12 15:39:56 2008
+++ src/sqlite.h.in Sat Jul 19 15:13:05 2008
@@ -35,6 +35,7 @@
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
#include <stdarg.h> /* Needed for the definition of va_list */
+#include <stdint.h>
/*
** Make sure we can call this stuff from C++.
@@ -188,6 +189,9 @@ typedef struct sqlite3 sqlite3;
** {F10202} The [sqlite_uint64] and [sqlite3_uint64] types specify
** a 64-bit unsigned integer.
*/
+typedef int64_t sqlite_int64;
+typedef uint64_t sqlite_uint64;
+#if 0
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
@@ -197,6 +201,7 @@ typedef struct sqlite3 sqlite3;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
+#endif
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-src_utf_c,v 1.1 2008/07/23 17:31:17 martynas Exp $
--- src/utf.c.orig Tue May 13 15:52:22 2008
+++ src/utf.c Sat Jul 19 15:10:45 2008
@@ -40,12 +40,6 @@
#include "vdbeInt.h"
/*
-** The following constant value is used by the SQLITE_BIGENDIAN and
-** SQLITE_LITTLEENDIAN macros.
-*/
-const int sqlite3one = 1;
-
-/*
** This lookup table is used to help decode the first byte of
** a multi-byte UTF8 character.
*/

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-src_util_c,v 1.1 2008/07/23 17:31:17 martynas Exp $
--- src/util.c.orig Tue May 13 19:41:50 2008
+++ src/util.c Sat Jul 19 15:10:45 2008
@@ -19,23 +19,14 @@
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>
+#include <math.h>
/*
** Return true if the floating point value is Not a Number.
*/
int sqlite3IsNaN(double x){
- /* This NaN test sometimes fails if compiled on GCC with -ffast-math.
- ** On the other hand, the use of -ffast-math comes with the following
- ** warning:
- **
- ** This option [-ffast-math] should never be turned on by any
- ** -O option since it can result in incorrect output for programs
- ** which depend on an exact implementation of IEEE or ISO
- ** rules/specifications for math functions.
- */
- volatile double y = x;
- return x!=y;
+ return isnan(x);
}
/*

View File

@ -1,8 +1,8 @@
@comment $OpenBSD: PLIST-main,v 1.2 2007/01/16 23:24:32 espie Exp $
@comment $OpenBSD: PLIST-main,v 1.3 2008/07/23 17:31:18 martynas Exp $
@pkgpath databases/sqlite3
@pkgpath databases/sqlite3,no_tcl
%%SHARED%%
bin/sqlite3
@bin bin/sqlite3
include/sqlite3.h
include/sqlite3ext.h
lib/libsqlite3.a