Changeset: 59b60bbc624f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=59b60bbc624f
Added Files:
clients/python3/test/control.py
sql/server/rel_planner.c
sql/server/rel_planner.h
Modified Files:
clients/Tests/exports.stable.out
clients/python2/monetdb/__init__.py
clients/python2/monetdb/control.py
clients/python2/monetdb/exceptions.py
clients/python2/monetdb/mapi.py
clients/python2/monetdb/sql/__init__.py
clients/python2/monetdb/sql/connections.py
clients/python2/monetdb/sql/converters.py
clients/python2/monetdb/sql/cursors.py
clients/python2/monetdb/sql/monetize.py
clients/python2/monetdb/sql/pythonize.py
clients/python2/monetdb/sql/types.py
clients/python3/monetdb/__init__.py
clients/python3/monetdb/control.py
clients/python3/monetdb/exceptions.py
clients/python3/monetdb/mapi.py
clients/python3/monetdb/sql/__init__.py
clients/python3/monetdb/sql/connections.py
clients/python3/monetdb/sql/converters.py
clients/python3/monetdb/sql/cursors.py
clients/python3/monetdb/sql/monetize.py
clients/python3/monetdb/sql/pythonize.py
clients/python3/monetdb/sql/types.py
gdk/ChangeLog.Feb2013
gdk/gdk_atoms.c
gdk/gdk_bbp.c
gdk/gdk_calc_private.h
gdk/gdk_mapreduce.c
gdk/gdk_select.c
gdk/gdk_utils.c
monetdb5/extras/jaql/jaqlgencode.c
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_instruction.h
monetdb5/mal/mal_properties.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/profiler.h
monetdb5/modules/mal/remote.c
monetdb5/optimizer/opt_mergetable.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.mx
sql/backends/monet5/vaults/mseed.c
sql/common/sql_list.c
sql/common/sql_types.h
sql/server/Makefile.ag
sql/server/rel_optimizer.c
sql/server/rel_optimizer.h
sql/server/rel_select.c
sql/server/sql_scan.h
sql/server/sql_semantic.h
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_storage.h
sql/storage/store.c
tools/merovingian/client/monetdb.c
Branch: mutation
Log Message:
Merge with default
diffs (truncated from 4564 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1836,7 +1836,6 @@ str OPTvectorOid(Client cntxt, MalBlkPtr
str OPTwrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
str PCREcompile_wrap(pcre **res, str *pattern);
str PCREexec_wrap(bit *res, pcre *pattern, str *s);
-str PCREfromstr(str instr, int *l, pcre **val);
str PCREilike2(bit *ret, str *s, str *pat);
str PCREilike3(bit *ret, str *s, str *pat, str *esc);
str PCREilike_join_pcre(int *l, int *r, int *b, int *pat, str *esc);
@@ -1861,10 +1860,8 @@ str PCREpatindex(int *ret, str *pat, str
str PCREquote(str *r, str *v);
str PCREreplace_bat_wrap(int *res, int *or, str *pat, str *repl, str *flags);
str PCREreplace_wrap(str *res, str *or, str *pat, str *repl, str *flags);
-str PCREselect(int *res, str *pattern, int *bid, bit *ignore);
str PCREselectDef(int *res, str *pattern, int *bid);
str PCREsql2pcre(str *ret, str *pat, str *esc);
-str PCREuselect(int *res, str *pattern, int *bid, bit *ignore);
str PCREuselectDef(int *res, str *pattern, int *bid);
str PQdequeue_anymax(int *ret, int *bid);
str PQdequeue_anymin(int *ret, int *bid);
@@ -2901,7 +2898,7 @@ str partitionRef;
str passRef;
str pcreRef;
void pcre_del(Heap *h, var_t *index);
-int pcre_fromstr(str instr, int *l, pcre **val);
+int pcre_fromstr(const char *instr, int *l, pcre **val);
BUN pcre_hash(pcre *b);
void pcre_heap(Heap *heap, size_t capacity);
str pcre_init(void);
diff --git a/clients/python2/monetdb/__init__.py
b/clients/python2/monetdb/__init__.py
--- a/clients/python2/monetdb/__init__.py
+++ b/clients/python2/monetdb/__init__.py
@@ -32,4 +32,3 @@ __all__ = ["sql", "mapi"]
# for backwards compatability
monetdb_exceptions = exceptions
-
diff --git a/clients/python2/monetdb/control.py
b/clients/python2/monetdb/control.py
--- a/clients/python2/monetdb/control.py
+++ b/clients/python2/monetdb/control.py
@@ -20,6 +20,7 @@ def parse_statusline(line):
subparts = rest.split(',')
sub_iter = iter(subparts)
+
info = {}
info['name'] = sub_iter.next()
diff --git a/clients/python2/monetdb/exceptions.py
b/clients/python2/monetdb/exceptions.py
--- a/clients/python2/monetdb/exceptions.py
+++ b/clients/python2/monetdb/exceptions.py
@@ -18,6 +18,7 @@
MonetDB Python API specific exceptions
"""
+
class Warning(StandardError):
"""Exception raised for important warnings like data
truncations while inserting, etc. It must be a subclass of
@@ -25,6 +26,7 @@ class Warning(StandardError):
exceptions)."""
pass
+
class Error(StandardError):
"""Exception that is the base class of all other error
exceptions. You can use this to catch all errors with one
@@ -41,17 +43,20 @@ class InterfaceError(Error):
must be a subclass of Error."""
pass
+
class DatabaseError(Error):
"""Exception raised for errors that are related to the
database. It must be a subclass of Error."""
pass
+
class DataError(DatabaseError):
"""Exception raised for errors that are due to problems with
the processed data like division by zero, numeric value
out of range, etc. It must be a subclass of DatabaseError."""
pass
+
class OperationalError(DatabaseError):
"""Exception raised for errors that are related to the
database's operation and not necessarily under the control
@@ -61,12 +66,14 @@ class OperationalError(DatabaseError):
processing, etc. It must be a subclass of DatabaseError."""
pass
+
class IntegrityError(DatabaseError):
"""Exception raised when the relational integrity of the
database is affected, e.g. a foreign key check fails. It
must be a subclass of DatabaseError."""
pass
+
class InternalError(DatabaseError):
"""Exception raised when the database encounters an internal
error, e.g. the cursor is not valid anymore, the
@@ -74,6 +81,7 @@ class InternalError(DatabaseError):
DatabaseError."""
pass
+
class ProgrammingError(DatabaseError):
"""Exception raised for programming errors, e.g. table not
found or already exists, syntax error in the SQL
@@ -81,11 +89,10 @@ class ProgrammingError(DatabaseError):
must be a subclass of DatabaseError."""
pass
+
class NotSupportedError(DatabaseError):
"""Exception raised in case a method or database API was used which is not
supported by the database, e.g. requesting a .rollback() on a connection
that does not support transaction or has transactions turned off. It must
be a subclass of DatabaseError."""
pass
-
-
diff --git a/clients/python2/monetdb/mapi.py b/clients/python2/monetdb/mapi.py
--- a/clients/python2/monetdb/mapi.py
+++ b/clients/python2/monetdb/mapi.py
@@ -24,13 +24,14 @@ import logging
import struct
import hashlib
from cStringIO import StringIO
-import time
-from monetdb.exceptions import OperationalError, DatabaseError,
ProgrammingError, NotSupportedError
+
+from monetdb.exceptions import OperationalError, DatabaseError,\
+ ProgrammingError, NotSupportedError
logger = logging.getLogger("monetdb")
-MAX_PACKAGE_LENGTH = (1024*8)-2
+MAX_PACKAGE_LENGTH = (1024 * 8) - 2
MSG_PROMPT = ""
MSG_MORE = "\1\2\n"
@@ -52,6 +53,7 @@ STATE_INIT = 0
STATE_READY = 1
+# noinspection PyExceptionInherit
class Connection(object):
"""
MAPI (low level MonetDB API) connection
@@ -87,7 +89,6 @@ class Connection(object):
self.socket.connect((hostname, port))
self.__login()
-
def __login(self, iteration=0):
""" Reads challenge from line, generate response and check if
everything is okay """
@@ -97,13 +98,13 @@ class Connection(object):
self.__putblock(response)
prompt = self.__getblock().strip()
- if len(prompt) == 0 :
+ if len(prompt) == 0:
# Empty response, server is happy
pass
elif prompt == MSG_OK:
pass
elif prompt.startswith(MSG_INFO):
- logger.info("II %s" % prompt[1:])
+ logger.info("%s" % prompt[1:])
elif prompt.startswith(MSG_ERROR):
logger.error(prompt[1:])
@@ -114,23 +115,22 @@ class Connection(object):
# the first
redirect = prompt.split()[0][1:].split(':')
if redirect[1] == "merovingian":
- logger.debug("II: merovingian proxy, restarting " +
- "authenticatiton")
+ logger.debug("restarting authentication")
if iteration <= 10:
- self.__login(iteration=iteration+1)
+ self.__login(iteration=iteration + 1)
else:
- raise OperationalError("maximal number of redirects " +
- "reached (10)")
+ raise OperationalError("maximal number of redirects "
+ "reached (10)")
elif redirect[1] == "monetdb":
self.hostname = redirect[2][2:]
self.port, self.database = redirect[3].split('/')
self.port = int(self.port)
- logger.info("II: merovingian redirect to monetdb://%s:%s/%s" %
- (self.hostname, self.port, self.database))
+ logger.info("redirect to monetdb://%s:%s/%s" %
+ (self.hostname, self.port, self.database))
self.socket.close()
self.connect(self.hostname, self.port, self.username,
- self.password, self.database, self.language)
+ self.password, self.database, self.language)
else:
raise ProgrammingError("unknown redirect: %s" % prompt)
@@ -141,16 +141,14 @@ class Connection(object):
self.state = STATE_READY
return True
-
def disconnect(self):
""" disconnect from the monetdb server """
self.state = STATE_INIT
self.socket.close()
-
def cmd(self, operation):
""" put a mapi command on the line"""
- logger.debug("II: executing command %s" % operation)
+ logger.debug("executing command %s" % operation)
if self.state != STATE_READY:
raise(ProgrammingError, "Not connected")
@@ -171,7 +169,6 @@ class Connection(object):
else:
raise ProgrammingError("unknown state: %s" % response)
-
def __challenge_response(self, challenge):
""" generate a response to a mapi login challenge """
challenges = challenge.split(':')
@@ -201,11 +198,11 @@ class Connection(object):
m.update(salt.encode())
pwhash = "{MD5}" + m.hexdigest()
else:
- raise NotSupportedError("Unsupported hash algorithms required for
login: %s" % (hashes));
+ raise NotSupportedError("Unsupported hash algorithms required"
+ " for login: %s" % hashes)
return ":".join(["BIG", self.username, pwhash, self.language,
- self.database]) + ":"
-
+ self.database]) + ":"
def __getblock(self):
""" read one mapi encoded block """
@@ -213,50 +210,41 @@ class Connection(object):
last = 0
while not last:
flag = self.__getbytes(2)
- unpacked = struct.unpack('<H', flag)[0] # unpack little endian
short
+ unpacked = struct.unpack('<H', flag)[0] # little endian short
length = unpacked >> 1
last = unpacked & 1
- #logger.debug("II: reading %i bytes, last: %s" % (length,
bool(last)))
result.write(self.__getbytes(length))
- #logger.debug("RX: %s" % result.getvalue())
return result.getvalue()
-
- def __getbytes(self, bytes):
+ def __getbytes(self, bytes_):
"""Read an amount of bytes from the socket"""
result = StringIO()
- count = bytes
+ count = bytes_
while count > 0:
recv = self.socket.recv(count)
if len(recv) == 0:
raise OperationalError("Server closed connection")
- #logger.debug("II: package size: %i payload: %s" % (len(recv),
recv))
count -= len(recv)
result.write(recv)
return result.getvalue()
-
def __putblock(self, block):
""" wrap the line in mapi format and put it into the socket """
pos = 0
last = 0
while not last:
- data = block[pos:pos+MAX_PACKAGE_LENGTH]
+ data = block[pos:pos + MAX_PACKAGE_LENGTH]
length = len(data)
if length < MAX_PACKAGE_LENGTH:
last = 1
- flag = struct.pack( '<H', ( length << 1 ) + last )
- #logger.debug("II: sending %i bytes, last: %s" % (length,
bool(last)))
- #logger.debug("TX: %s" % data)
+ flag = struct.pack('<H', (length << 1) + last)
self.socket.send(flag)
self.socket.send(data)
pos += length
-
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list