diff options
author | Robert Haas | 2010-11-20 15:04:48 +0000 |
---|---|---|
committer | Robert Haas | 2010-11-20 15:04:48 +0000 |
commit | 4343c0e546b216ab38a3397a4f0f7476d557b352 (patch) | |
tree | 5a5676ac12ebe9f480851e2bb963ac1418c86921 /contrib | |
parent | e8bf683fbee935181e207d7171630194ed01f6a1 (diff) |
Expose quote_literal_cstr() from core.
This eliminates the need for inefficient implementions of this
functionality in both contrib/dblink and contrib/tablefunc, so remove
them. The upcoming patch implementing an in-core format() function
will also require this functionality.
In passing, add some regression tests.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/dblink/dblink.c | 20 | ||||
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 20 |
2 files changed, 0 insertions, 40 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index ce86829210..30f1b0eab0 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -91,7 +91,6 @@ static char **get_text_array_contents(ArrayType *array, int *numitems); static char *get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals, char **tgt_pkattvals); static char *get_sql_delete(Relation rel, int *pkattnums, int pknumatts, char **tgt_pkattvals); static char *get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals, char **tgt_pkattvals); -static char *quote_literal_cstr(char *rawstr); static char *quote_ident_cstr(char *rawstr); static int get_attnum_pk_pos(int *pkattnums, int pknumatts, int key); static HeapTuple get_tuple_of_interest(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals); @@ -1894,25 +1893,6 @@ get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals } /* - * Return a properly quoted literal value. - * Uses quote_literal in quote.c - */ -static char * -quote_literal_cstr(char *rawstr) -{ - text *rawstr_text; - text *result_text; - char *result; - - rawstr_text = cstring_to_text(rawstr); - result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, - PointerGetDatum(rawstr_text))); - result = text_to_cstring(result_text); - - return result; -} - -/* * Return a properly quoted identifier. * Uses quote_ident in quote.c */ diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index ea2f2e15b0..2e9ea1a626 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -85,7 +85,6 @@ static Tuplestorestate *build_tuplestore_recursively(char *key_fld, MemoryContext per_query_ctx, AttInMetadata *attinmeta, Tuplestorestate *tupstore); -static char *quote_literal_cstr(char *rawstr); typedef struct { @@ -1564,22 +1563,3 @@ compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) /* OK, the two tupdescs are compatible for our purposes */ return true; } - -/* - * Return a properly quoted literal value. - * Uses quote_literal in quote.c - */ -static char * -quote_literal_cstr(char *rawstr) -{ - text *rawstr_text; - text *result_text; - char *result; - - rawstr_text = cstring_to_text(rawstr); - result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, - PointerGetDatum(rawstr_text))); - result = text_to_cstring(result_text); - - return result; -} |