Puppet: System Administration Automated

Support

Ticket #1003 (closed defect: fixed)

Opened 11 months ago

Last modified 9 months ago

Collection Selector expressions broken

Reported by: DavidS Assigned to: community
Priority: normal Milestone: 0.24.2
Component: language Version: 0.24.1
Severity: normal Keywords: sql, rails, collection, collexpr, collector
Cc: Triage Stage: Accepted
Attached Patches: Code Complexity: Unknown

Description

Using Debian's 0.24.1-1 with postgres 8.1 on etch, I get the following error when trying to collect tagged resources:

ERROR:  invalid input syntax for type boolean: "param_values.value = 'bind' and param_names.name = 'tags'"

The SQL statement in question looks like this (reformatted):

SELECT 
   resources."id" AS t0_r0,
   resources."title" AS t0_r1,
   [...]
FROM
   resources
   LEFT OUTER JOIN param_values ON param_values.resource_id = resources.id 
   LEFT OUTER JOIN param_names ON param_names.id = param_values.param_name_id
WHERE
   (host_id != 9 AND (exported='t' AND restype='File')
   AND
   ('param_values.value = ''bind'' and param_names.name = ''tags'''))

This is caused by this manifest snippet:

File<<| tags == bind |>>

and can be fixed by applying this patch:

diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index b8165a8..ec57b0d 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -51,7 +51,7 @@ class Puppet::Parser::Collector
         search = "(exported=? AND restype=?)"
         values = [true, @type]

-        search += " AND (?)" and values << @equery if @equery
+        search += " AND (%s)" % @equery if @equery

         # We're going to collect objects from rails, but we don't want any
         # objects from this host.

adding @equery to values causes rails to "correctly" quote it as a value, but this is of course not the intended thing to quote, since it contains the query snippet which was generated in lib/puppet/parser/ast/collexpr.rb:evaluate.

I'm not sure whether this is totally the right patch, but it Woskr For Me[tm].

Change History

01/28/08 04:20:38 changed by luke

  • stage changed from Unreviewed to Accepted.
  • milestone set to 0.24.2.

02/13/08 23:36:46 changed by luke

  • status changed from new to closed.
  • resolution set to fixed.

Applied in [fe02591].