Applied COPY patch from Alejandro Dubrovsky (missing files and project)

This commit is contained in:
Federico Di Gregorio 2008-11-25 17:46:15 +01:00
parent c1d6073531
commit 4e359f6f05
3 changed files with 61 additions and 0 deletions

43
psycopg/utils.c Normal file
View File

@ -0,0 +1,43 @@
/* utils.c - miscellaneous utility functions
*
*/
#include "psycopg/config.h"
#include "psycopg/utils.h"
#include "psycopg/psycopg.h"
#include "psycopg/connection.h"
#include "psycopg/pgtypes.h"
#include "psycopg/pgversion.h"
#include <string.h>
#include <stdlib.h>
char *psycopg_internal_escape_string(connectionObject *conn, const char *string)
{
char *buffer;
size_t string_length;
int equote; /* buffer offset if E'' quotes are needed */
string_length = strlen(string);
buffer = (char *) malloc((string_length * 2 + 4) * sizeof(char));
if (buffer == NULL) {
return NULL;
}
equote = (conn && (conn->equote)) ? 1 : 0;
{
size_t qstring_length;
qstring_length = qstring_escape(buffer + equote + 1, string, string_length,
(conn ? conn->pgconn : NULL));
if (equote)
buffer[0] = 'E';
buffer[equote] = '\'';
buffer[qstring_length + equote + 1] = '\'';
buffer[qstring_length + equote + 2] = 0;
}
return buffer;
}

16
psycopg/utils.h Normal file
View File

@ -0,0 +1,16 @@
/* utils.h - miscellaneous utility functions
*
*/
#ifndef PSYCOPG_UTILS_H
#define PSYCOPG_UTILS_H 1
#include "psycopg/config.h"
#include "psycopg/connection.h"
HIDDEN char *psycopg_internal_escape_string(connectionObject *conn, const char *string);
#endif /* !defined(PSYCOPG_UTILS_H) */

View File

@ -134,6 +134,8 @@
<File name="tests/Makefile" subtype="Code" buildaction="Nothing" /> <File name="tests/Makefile" subtype="Code" buildaction="Nothing" />
<File name="tests/runtests.py" subtype="Code" buildaction="Nothing" /> <File name="tests/runtests.py" subtype="Code" buildaction="Nothing" />
<File name="tests/types_extras.py" subtype="Code" buildaction="Nothing" /> <File name="tests/types_extras.py" subtype="Code" buildaction="Nothing" />
<File name="psycopg/utils.c" subtype="Code" buildaction="Compile" />
<File name="psycopg/utils.h" subtype="Code" buildaction="Nothing" />
</Contents> </Contents>
<compiler ctype="GccCompiler" /> <compiler ctype="GccCompiler" />
<MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" /> <MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" />