handling NULL in some library functions properly

git-tfs-id: [http://falcon:8080/tfs/Projects]$/Phalanger/Main;C3886
PDO closes pending reader before commit properly

git-tfs-id: [http://falcon:8080/tfs/Projects]$/Phalanger/Main;C3887