summaryrefslogtreecommitdiff
path: root/sandbox
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-11-28 03:44:14 +0000
committerFederico Di Gregorio <fog@initd.org>2005-11-28 03:44:14 +0000
commit8ffafd75eb1ad03393891b8c86cf34d662a8ed1b (patch)
treee296fc6b4a100bffcb34867ea8b484621845614d /sandbox
parentad76b5ba3cc01b658e31fb3c4e94340ba0f884d9 (diff)
downloadpsycopg2-8ffafd75eb1ad03393891b8c86cf34d662a8ed1b.tar.gz
Added sandbox stuff to the repository.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/async.py36
-rw-r--r--sandbox/crash.py25
-rw-r--r--sandbox/typecrash.py7
-rw-r--r--sandbox/valgrind-python.supp486
4 files changed, 554 insertions, 0 deletions
diff --git a/sandbox/async.py b/sandbox/async.py
new file mode 100644
index 0000000..17e96d0
--- /dev/null
+++ b/sandbox/async.py
@@ -0,0 +1,36 @@
+import datetime
+import time
+import psycopg2
+
+#d = datetime.timedelta(12, 100, 9876)
+#print d.days, d.seconds, d.microseconds
+#print psycopg.adapt(d).getquoted()
+
+conn = psycopg2.connect("dbname=test_unicode")
+conn.set_client_encoding("xxx")
+curs = conn.cursor()
+#curs.execute("SELECT 1.0 AS foo")
+#print curs.fetchmany(2)
+#print curs.fetchall()
+
+def sleep(curs):
+ while not curs.isready():
+ print "."
+ time.sleep(.1)
+
+#curs.execute("""
+# DECLARE zz INSENSITIVE SCROLL CURSOR WITH HOLD FOR
+# SELECT now();
+# FOR READ ONLY;""", async = 1)
+curs.execute("SELECT now() AS foo", async=1);
+sleep(curs)
+print curs.fetchall()
+
+#curs.execute("""
+# FETCH FORWARD 1 FROM zz;""", async = 1)
+curs.execute("SELECT now() AS bar", async=1);
+print curs.fetchall()
+
+curs.execute("SELECT now() AS bar");
+sleep(curs)
+
diff --git a/sandbox/crash.py b/sandbox/crash.py
new file mode 100644
index 0000000..23f354c
--- /dev/null
+++ b/sandbox/crash.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+#import psycopg as db
+import psycopg2 as db
+import threading
+import time
+import sys
+
+def query_worker(dsn):
+ conn = db.connect(dsn)
+ cursor = conn.cursor()
+ while True:
+ cursor.execute("select * from pg_class")
+ while True:
+ row = cursor.fetchone()
+ if row is None:
+ break
+
+if len(sys.argv) != 2:
+ print 'usage: %s DSN' % sys.argv[0]
+ sys.exit(1)
+th = threading.Thread(target=query_worker, args=(sys.argv[1],))
+th.setDaemon(True)
+th.start()
+time.sleep(1)
diff --git a/sandbox/typecrash.py b/sandbox/typecrash.py
new file mode 100644
index 0000000..522ab54
--- /dev/null
+++ b/sandbox/typecrash.py
@@ -0,0 +1,7 @@
+import psycopg2.extensions
+
+print dir(psycopg2._psycopg)
+print psycopg2.extensions.new_type(
+ (600,), "POINT", lambda oids, name, fun: None)
+print "ciccia ciccia"
+print psycopg2._psycopg
diff --git a/sandbox/valgrind-python.supp b/sandbox/valgrind-python.supp
new file mode 100644
index 0000000..0938184
--- /dev/null
+++ b/sandbox/valgrind-python.supp
@@ -0,0 +1,486 @@
+#
+# This is a valgrind suppression file that should be used when using valgrind.
+#
+# Here's an example of running valgrind:
+#
+# cd python/dist/src
+# valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \
+# ./python -E -tt ./Lib/test/regrtest.py -u bsddb,network
+#
+# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER
+# to use the preferred suppressions with Py_ADDRESS_IN_RANGE.
+#
+# If you do not want to recompile Python, you can uncomment
+# suppressions for PyObject_Free and PyObject_Realloc.
+#
+# See Misc/README.valgrind for more information.
+
+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Addr4
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Value4
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64)
+ Memcheck:Value8
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+ Memcheck:Cond
+ fun:Py_ADDRESS_IN_RANGE
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Addr4
+ fun:PyObject_Free
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Value4
+ fun:PyObject_Free
+}
+
+{
+ ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+ Memcheck:Cond
+ fun:PyObject_Free
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Addr4
+ fun:PyObject_Realloc
+}
+
+{
+ ADDRESS_IN_RANGE/Invalid read of size 4
+ Memcheck:Value4
+ fun:PyObject_Realloc
+}
+
+{
+ ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
+ Memcheck:Cond
+ fun:PyObject_Realloc
+}
+
+###
+### All the suppressions below are for errors that occur within libraries
+### that Python uses. The problems to not appear to be related to Python's
+### use of the libraries.
+###
+{
+ GDBM problems, see test_gdbm
+ Memcheck:Param
+ write(buf)
+ fun:write
+ fun:gdbm_open
+
+}
+
+{
+ Avoid problem in libc on gentoo
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+}
+
+{
+ Avoid problem in glibc on gentoo
+ Memcheck:Addr8
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libdl-2.3.5.so
+ fun:dlopen
+}
+
+{
+ Avoid problem in glibc on gentoo
+ Memcheck:Addr8
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libdl-2.3.5.so
+ fun:dlopen
+}
+
+{
+ Avoid problem in glibc on gentoo
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libdl-2.3.5.so
+ fun:dlopen
+}
+
+{
+ Avoid problem in glibc on gentoo
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/libdl-2.3.5.so
+ fun:dlopen
+}
+
+{
+ Avoid problems w/readline doing a putenv and leaking on exit
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:sh_set_lines_and_columns
+ fun:_rl_get_screen_size
+ fun:_rl_init_terminal_io
+ obj:/lib/libreadline.so.4.3
+ fun:rl_initialize
+ fun:setup_readline
+ fun:initreadline
+ fun:_PyImport_LoadDynamicModule
+ fun:load_module
+ fun:import_submodule
+ fun:load_next
+ fun:import_module_ex
+ fun:PyImport_ImportModuleEx
+}
+
+{
+ Mysterious leak that seems to deal w/pthreads
+ Memcheck:Leak
+ fun:calloc
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_allocate_tls
+ fun:__pthread_initialize_minimal
+}
+
+{
+ Mysterious leak that seems to deal w/pthreads
+ Memcheck:Leak
+ fun:memalign
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_allocate_tls
+ fun:__pthread_initialize_minimal
+}
+
+###
+### These occur from somewhere within the SSL, when running
+### test_socket_sll. They are too general to leave on by default.
+###
+###{
+### somewhere in SSL stuff
+### Memcheck:Cond
+### fun:memset
+###}
+###{
+### somewhere in SSL stuff
+### Memcheck:Value4
+### fun:memset
+###}
+###
+###{
+### somewhere in SSL stuff
+### Memcheck:Cond
+### fun:MD5_Update
+###}
+###
+###{
+### somewhere in SSL stuff
+### Memcheck:Value4
+### fun:MD5_Update
+###}
+
+#
+# All of these problems come from using test_socket_ssl
+#
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_bin2bn
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_num_bits_word
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:BN_num_bits_word
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_mod_exp_mont_word
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BN_mod_exp_mont
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Param
+ write(buf)
+ fun:write
+ obj:/usr/lib/libcrypto.so.0.9.7
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:RSA_verify
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:RSA_verify
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:DES_set_key_unchecked
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:DES_encrypt2
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ obj:/usr/lib/libssl.so.0.9.7
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ obj:/usr/lib/libssl.so.0.9.7
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:BUF_MEM_grow_clean
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:memcpy
+ fun:ssl3_read_bytes
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Cond
+ fun:SHA1_Update
+}
+
+{
+ from test_socket_ssl
+ Memcheck:Value4
+ fun:SHA1_Update
+}
+
+
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ fun:dlopen
+ fun:_PyImport_GetDynLoadFunc
+ fun:_PyImport_LoadDynamicModule
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ fun:dlopen
+ fun:_PyImport_GetDynLoadFunc
+ fun:_PyImport_LoadDynamicModule
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Addr4
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ fun:dlopen
+ fun:_PyImport_GetDynLoadFunc
+ fun:_PyImport_LoadDynamicModule
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Addr4
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ fun:dlopen
+ fun:_PyImport_GetDynLoadFunc
+ fun:_PyImport_LoadDynamicModule
+ obj:/usr/bin/python2.3
+ obj:/usr/bin/python2.3
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:__libc_dlopen_mode
+ fun:__nss_lookup_function
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ fun:__nss_passwd_lookup
+ fun:getpwuid_r
+ fun:pqGetpwuid
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:__libc_dlopen_mode
+ fun:__nss_lookup_function
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ fun:__nss_passwd_lookup
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Addr4
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:__libc_dlopen_mode
+ fun:__nss_lookup_function
+ obj:/lib/tls/i686/cmov/libnss_compat-2.3.5.so
+ fun:_nss_compat_getpwuid_r
+}
+
+{
+ Debian unstable with libc-i686 suppressions
+ Memcheck:Cond
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libc-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ fun:_dl_open
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ obj:/lib/ld-2.3.5.so
+ obj:/lib/tls/i686/cmov/libdl-2.3.5.so
+ fun:dlopen
+ fun:_PyImport_GetDynLoadFunc
+ fun:_PyImport_LoadDynamicModule
+ obj:/usr/bin/python2.4
+ obj:/usr/bin/python2.4
+}