diff options
author | Sean Bright <sean@malleable.com> | 2008-06-29 12:06:46 +0000 |
---|---|---|
committer | Sean Bright <sean@malleable.com> | 2008-06-29 12:06:46 +0000 |
commit | 044a7b945f28b837b3fc987f236cee28e0429e46 (patch) | |
tree | 1304a3cb58e7972f5d0ae3c8be92513b61677e93 /cdr/cdr_pgsql.c | |
parent | 19830f3359c6a6d9537b7c2d519ebaa663d091f6 (diff) |
Quote column names when inserting CDRs into postgres to avoid conflicts
with reserved words.
(closes issue #12947)
Reported by: panolex
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@126274 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'cdr/cdr_pgsql.c')
-rw-r--r-- | cdr/cdr_pgsql.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c index ffc520358..e4d9b692c 100644 --- a/cdr/cdr_pgsql.c +++ b/cdr/cdr_pgsql.c @@ -146,8 +146,8 @@ static int pgsql_log(struct ast_cdr *cdr) if (!value) { if (cur->notnull && !cur->hasdefault) { /* Field is NOT NULL (but no default), must include it anyway */ - LENGTHEN_BUF1(strlen(cur->name)); - lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name); + LENGTHEN_BUF1(strlen(cur->name) + 2); + lensql += snprintf(sql + lensql, sizesql - lensql, "\"%s\",", cur->name); LENGTHEN_BUF2(3); strcat(sql2, "'',"); lensql2 += 3; @@ -155,8 +155,8 @@ static int pgsql_log(struct ast_cdr *cdr) continue; } - LENGTHEN_BUF1(strlen(cur->name)); - lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name); + LENGTHEN_BUF1(strlen(cur->name) + 2); + lensql += snprintf(sql + lensql, sizesql - lensql, "\"%s\",", cur->name); if (strcmp(cur->name, "start") == 0 || strcmp(cur->name, "calldate") == 0) { if (strncmp(cur->type, "int", 3) == 0) { |